Java Code Examples for android.graphics.RectF#set()
The following examples show how to use
android.graphics.RectF#set() .
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: MaterialProgressDrawable.java From RefreshLayout with Apache License 2.0 | 6 votes |
/** * Draw the progress spinner */ public void draw(Canvas c, Rect bounds) { final RectF arcBounds = mTempBounds; arcBounds.set(bounds); arcBounds.inset(mStrokeInset, mStrokeInset); final float startAngle = (mStartTrim + mRotation) * 360; final float endAngle = (mEndTrim + mRotation) * 360; float sweepAngle = endAngle - startAngle; mPaint.setColor(mCurrentColor); c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint); drawTriangle(c, startAngle, sweepAngle, bounds); if (mAlpha < 255) { mCirclePaint.setColor(mBackgroundColor); mCirclePaint.setAlpha(255 - mAlpha); c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2, mCirclePaint); } }
Example 2
Source File: GLetter.java From CoolAndroidAnim with Apache License 2.0 | 6 votes |
public GLetter(int x, int y) { super(x, y); mPath = new Path(); mMoveX = mCurX + SHIFT; mMoveY = mCurY - SHIFT; mPath.moveTo(mMoveX, mMoveY); mFv = mDuration * 2 / 3; mRectFHalf = new RectF(); mRectFHalf.set(mCurX - SHIFT, mCurY - SHIFT + LEG_LENGTH - SHIFT, mCurX + SHIFT, mCurY + SHIFT + LEG_LENGTH - SHIFT); mSweepAngleHalf = 0; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(Config.WHITE); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(STROKE_WIDTH); mRectF = new RectF(); mRectF.set(mCurX - SHIFT, mCurY - SHIFT, mCurX + SHIFT, mCurY + SHIFT); mStartAngle = 0; mSweepAngle = 0; }
Example 3
Source File: MaterialProgressDrawable.java From AndroidUiKit with Apache License 2.0 | 6 votes |
/** * Draw the progress spinner */ public void draw(Canvas c, Rect bounds) { final RectF arcBounds = mTempBounds; arcBounds.set(bounds); arcBounds.inset(mStrokeInset, mStrokeInset); final float startAngle = (mStartTrim + mRotation) * 360; final float endAngle = (mEndTrim + mRotation) * 360; float sweepAngle = endAngle - startAngle; mPaint.setColor(mCurrentColor); c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint); drawTriangle(c, startAngle, sweepAngle, bounds); if (mAlpha < 255) { mCirclePaint.setColor(mBackgroundColor); mCirclePaint.setAlpha(255 - mAlpha); c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2, mCirclePaint); } }
Example 4
Source File: HorizontalBarChart.java From android-kline with Apache License 2.0 | 6 votes |
@Override public void getBarBounds(BarEntry e, RectF outputRect) { RectF bounds = outputRect; IBarDataSet set = mData.getDataSetForEntry(e); if (set == null) { outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); return; } float y = e.getY(); float x = e.getX(); float barWidth = mData.getBarWidth(); float top = x - barWidth / 2f; float bottom = x + barWidth / 2f; float left = y >= 0 ? y : 0; float right = y <= 0 ? y : 0; bounds.set(left, top, right, bottom); getTransformer(set.getAxisDependency()).rectValueToPixel(bounds); }
Example 5
Source File: HorizontalBarChart.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public void getBarBounds(BarEntry e, RectF outputRect) { RectF bounds = outputRect; IBarDataSet set = mData.getDataSetForEntry(e); if (set == null) { outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); return; } float y = e.getY(); float x = e.getX(); float barWidth = mData.getBarWidth(); float top = x - barWidth / 2f; float bottom = x + barWidth / 2f; float left = y >= 0 ? y : 0; float right = y <= 0 ? y : 0; bounds.set(left, top, right, bottom); getTransformer(set.getAxisDependency()).rectValueToPixel(bounds); }
Example 6
Source File: MaterialProgressDrawable.java From weex with Apache License 2.0 | 6 votes |
/** * Draw the progress spinner */ public void draw(Canvas c, Rect bounds) { final RectF arcBounds = mTempBounds; arcBounds.set(bounds); arcBounds.inset(mStrokeInset, mStrokeInset); final float startAngle = (mStartTrim + mRotation) * 360; final float endAngle = (mEndTrim + mRotation) * 360; float sweepAngle = endAngle - startAngle; mPaint.setColor(mCurrentColor); c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint); drawTriangle(c, startAngle, sweepAngle, bounds); if (mAlpha < 255) { mCirclePaint.setColor(mBackgroundColor); mCirclePaint.setAlpha(255 - mAlpha); c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2, mCirclePaint); } }
Example 7
Source File: MarkerDrawable.java From SwipeBack with GNU General Public License v3.0 | 6 votes |
private void computePath(Rect bounds) { final float currentScale = mCurrentScale; final Path path = mPath; final RectF rect = mRect; final Matrix matrix = mMatrix; path.reset(); int totalSize = Math.min(bounds.width(), bounds.height()); float initial = mClosedStateSize; float destination = totalSize; float currentSize = initial + (destination - initial) * currentScale; float halfSize = currentSize / 2f; float inverseScale = 1f - currentScale; float cornerSize = halfSize * inverseScale; float[] corners = new float[]{halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize, cornerSize}; rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize); path.addRoundRect(rect, corners, Path.Direction.CCW); matrix.reset(); matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize); matrix.postTranslate((bounds.width() - currentSize) / 2, 0); float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale; matrix.postTranslate(0, hDiff); path.transform(matrix); }
Example 8
Source File: TransparentLayout.java From financisto with GNU General Public License v2.0 | 5 votes |
@Override protected void dispatchDraw(Canvas canvas) { RectF drawRect = new RectF(); drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight()); canvas.drawRoundRect(drawRect, 5, 5, innerPaint); canvas.drawRoundRect(drawRect, 5, 5, borderPaint); super.dispatchDraw(canvas); }
Example 9
Source File: UIBaseButton.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { if (mBackgroundPaint == null) { super.onDraw(canvas); return; } if (mShapeType == 0) { canvas.drawCircle(mWidth / 2, mHeight / 2, mWidth / 2, mBackgroundPaint); } else { RectF rectF = new RectF(); rectF.set(0, 0, mWidth, mHeight); canvas.drawRoundRect(rectF, mRadius, mRadius, mBackgroundPaint); } super.onDraw(canvas); }
Example 10
Source File: ForwardingDrawable.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** * Gets the transformed bounds of this drawable. * Note: bounds are not cropped (otherwise they would likely be the same as drawable's bounds). * @param outBounds rect to fill with bounds */ public void getTransformedBounds(RectF outBounds) { getParentTransform(sTempTransform); // IMPORTANT: {@code getBounds} should be called after {@code getParentTransform}, // because the parent may have to change our bounds. outBounds.set(getBounds()); sTempTransform.mapRect(outBounds); }
Example 11
Source File: ClipZoomImageView.java From Android with MIT License | 5 votes |
/** * According to the current image of the Matrix to obtain the scope of the picture * * @return */ private RectF getMatrixRectF() { Matrix matrix = mScaleMatrix; RectF rect = new RectF(); Drawable d = getDrawable(); if (null != d) { rect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); matrix.mapRect(rect); } return rect; }
Example 12
Source File: CropImageView.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
/** * @return 获取当前图片显示的矩形区域 */ private RectF getImageMatrixRect() { RectF rectF = new RectF(); rectF.set(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight()); matrix.mapRect(rectF); return rectF; }
Example 13
Source File: TiledImageRenderer.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
private void drawTile(GLCanvas canvas, int tx, int ty, int level, float x, float y, float length) { RectF source = mSourceRect; RectF target = mTargetRect; target.set(x, y, x + length, y + length); source.set(0, 0, mTileSize, mTileSize); Tile tile = getTile(tx, ty, level); if (tile != null) { if (!tile.isContentValid()) { if (tile.mTileState == STATE_DECODED) { if (mUploadQuota > 0) { --mUploadQuota; tile.updateContent(canvas); } else { mRenderComplete = false; } } else if (tile.mTileState != STATE_DECODE_FAIL){ mRenderComplete = false; queueForDecode(tile); } } if (drawTile(tile, canvas, source, target)) { return; } } if (mPreview != null) { int size = mTileSize << level; float scaleX = (float) mPreview.getWidth() / mImageWidth; float scaleY = (float) mPreview.getHeight() / mImageHeight; source.set(tx * scaleX, ty * scaleY, (tx + size) * scaleX, (ty + size) * scaleY); canvas.drawTexture(mPreview, source, target); } }
Example 14
Source File: GestureFloatingTextDrawingPreview.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
/** * Updates gesture preview text position based on mLastPointerCoords. */ protected void updatePreviewPosition() { if (mSuggestedWords.isEmpty() || TextUtils.isEmpty(mSuggestedWords.getWord(0))) { invalidateDrawingView(); return; } final String text = mSuggestedWords.getWord(0); final RectF rectangle = mGesturePreviewRectangle; final int textHeight = mParams.mGesturePreviewTextHeight; final float textWidth = mParams.getTextPaint().measureText(text); final float hPad = mParams.mGesturePreviewHorizontalPadding; final float vPad = mParams.mGesturePreviewVerticalPadding; final float rectWidth = textWidth + hPad * 2.0f; final float rectHeight = textHeight + vPad * 2.0f; final float rectX = Math.min( Math.max(CoordinateUtils.x(mLastPointerCoords) - rectWidth / 2.0f, 0.0f), mParams.mDisplayWidth - rectWidth); final float rectY = CoordinateUtils.y(mLastPointerCoords) - mParams.mGesturePreviewTextOffset - rectHeight; rectangle.set(rectX, rectY, rectX + rectWidth, rectY + rectHeight); mPreviewTextX = (int)(rectX + hPad + textWidth / 2.0f); mPreviewTextY = (int)(rectY + vPad) + textHeight; // TODO: Should narrow the invalidate region. invalidateDrawingView(); }
Example 15
Source File: InitialCenterCircleView.java From AnimatedCircleLoadingView with Apache License 2.0 | 5 votes |
public void drawCircle(Canvas canvas) { RectF oval = new RectF(); oval.set(parentCenter - currentCircleWidth, parentCenter - currentCircleHeight, parentCenter + currentCircleWidth, parentCenter + currentCircleHeight); canvas.drawOval(oval, paint); }
Example 16
Source File: MoveableImageView.java From VideoMeeting with Apache License 2.0 | 5 votes |
private RectF getMatrixRectF() { Matrix matrix = mScaleMatrix; RectF rectF = new RectF(); Drawable d = getDrawable(); if (d != null) { rectF.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); matrix.mapRect(rectF); } return rectF; }
Example 17
Source File: ScaleImageView.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
private RectF getMatrixRectF() { Matrix matrix = mMatrix; RectF rect = new RectF(); Drawable drawable = getDrawable(); if (null != drawable) { rect.set(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); matrix.mapRect(rect); } return rect; }
Example 18
Source File: GaugeAccelerationHolo.java From AccelerationAlert with Apache License 2.0 | 4 votes |
/** * Initialize the drawing related members of the instance. */ private void initDrawingTools() { rimRect = new RectF(0.1f, 0.1f, 0.9f, 0.9f); //inner rim oval innerRim = new RectF(0.25f, 0.25f, 0.75f, 0.75f); //inner most white dot innerMostDot = new RectF(0.47f, 0.47f, 0.53f, 0.53f); // the linear gradient is a bit skewed for realism rimPaint = new Paint(); rimPaint.setFlags(Paint.ANTI_ALIAS_FLAG); rimPaint.setShader(new LinearGradient(0.40f, 0.0f, 0.60f, 1.0f, Color .rgb(255, 255, 255), Color.rgb(255,255,255), Shader.TileMode.CLAMP)); float rimSize = 0.03f; faceRect = new RectF(); faceRect.set(rimRect.left + rimSize, rimRect.top + rimSize, rimRect.right - rimSize, rimRect.bottom - rimSize); rimShadowPaint = new Paint(); rimShadowPaint.setStyle(Paint.Style.FILL); rimShadowPaint.setAntiAlias(true); //set the size of the outside white with the rectangles. //a 'bigger' negative will increase the size. float rimOuterSize = -0.04f; rimOuterRect = new RectF(); rimOuterRect.set(rimRect.left + rimOuterSize, rimRect.top + rimOuterSize, rimRect.right - rimOuterSize, rimRect.bottom - rimOuterSize); rimOuterTopRect = new RectF(0.5f, 0.116f, 0.5f, 0.07f); rimOuterTopRect.set(rimOuterTopRect.left + rimOuterSize, rimOuterTopRect.top + rimOuterSize, rimOuterTopRect.right - rimOuterSize, rimOuterTopRect.bottom - rimOuterSize); rimOuterBottomRect = new RectF(0.5f, 0.93f, 0.5f, 0.884f); rimOuterBottomRect.set(rimOuterBottomRect.left + rimOuterSize, rimOuterBottomRect.top + rimOuterSize, rimOuterBottomRect.right - rimOuterSize, rimOuterBottomRect.bottom - rimOuterSize); rimOuterLeftRect = new RectF(0.116f, 0.5f, 0.07f, 0.5f); rimOuterLeftRect.set(rimOuterLeftRect.left + rimOuterSize, rimOuterLeftRect.top + rimOuterSize, rimOuterLeftRect.right - rimOuterSize, rimOuterLeftRect.bottom - rimOuterSize); rimOuterRightRect = new RectF(0.93f, 0.5f, 0.884f, 0.5f); rimOuterRightRect.set(rimOuterRightRect.left + rimOuterSize, rimOuterRightRect.top + rimOuterSize, rimOuterRightRect.right - rimOuterSize, rimOuterRightRect.bottom - rimOuterSize); //inner rim declarations the black oval/rect float rimInnerSize = 0.02f; innerface = new RectF(); innerface.set(innerRim.left + rimInnerSize, innerRim.top + rimInnerSize, innerRim.right - rimInnerSize, innerRim.bottom - rimInnerSize); //inner 4 small rectangles rimInnerTopRect = new RectF(0.46f, 0.23f, 0.54f, 0.26f); rimInnerBottomRect = new RectF(0.46f, 0.74f, 0.54f, 0.77f); rimInnerLeftRect = new RectF(0.23f, 0.54f, 0.26f, 0.46f); rimInnerRightRect = new RectF(0.74f, 0.54f, 0.77f, 0.46f); pointPaint = new Paint(); pointPaint.setAntiAlias(true); pointPaint.setColor(Color.WHITE); pointPaint.setShadowLayer(0.01f, -0.005f, -0.005f, 0x7f000000); pointPaint.setStyle(Paint.Style.FILL_AND_STROKE); backgroundPaint = new Paint(); backgroundPaint.setFilterBitmap(true); }
Example 19
Source File: MovementBounds.java From GestureViews with Apache License 2.0 | 4 votes |
/** * Calculating bounds for {@link State#x} & {@link State#y} values to keep image within * viewport and taking image gravity into account (see {@link Settings#setGravity(int)}). * * @param state State for which to calculate movement bounds. * @return Current movement bounds object for calls chaining. */ public MovementBounds set(State state) { RectF area = tmpRectF; GravityUtils.getMovementAreaPosition(settings, tmpRect); area.set(tmpRect); final Rect pos = tmpRect; if (settings.getFitMethod() == Settings.Fit.OUTSIDE) { // For OUTSIDE fit method we will rotate area rect instead of image rect, // that will help us correctly fit movement area inside image rect boundsRotation = state.getRotation(); boundsPivotX = area.centerX(); boundsPivotY = area.centerY(); if (!State.equals(boundsRotation, 0f)) { tmpMatrix.setRotate(-boundsRotation, boundsPivotX, boundsPivotY); tmpMatrix.mapRect(area); } } else { boundsRotation = 0f; boundsPivotX = boundsPivotY = 0f; } state.get(tmpMatrix); if (!State.equals(boundsRotation, 0f)) { // Removing image rotation tmpMatrix.postRotate(-boundsRotation, boundsPivotX, boundsPivotY); } GravityUtils.getImagePosition(tmpMatrix, settings, pos); // Calculating movement bounds for top-left corner of the scaled image switch (settings.getBoundsType()) { case NORMAL: calculateNormalBounds(area, pos); break; case INSIDE: calculateInsideBounds(area, pos); break; case OUTSIDE: calculateOutsideBounds(area, pos); break; case PIVOT: calculatePivotBounds(pos); break; case NONE: default: // Infinite bounds with overflow prevention bounds.set(Integer.MIN_VALUE >> 2, Integer.MIN_VALUE >> 2, Integer.MAX_VALUE >> 2, Integer.MAX_VALUE >> 2); break; } // We should also adjust bounds position, since top-left corner of rotated image rectangle // will be somewhere on the edge of non-rotated bounding rectangle. // Note: for OUTSIDE fit method image rotation was skipped above, so we will not need // to adjust bounds here. if (settings.getFitMethod() != Settings.Fit.OUTSIDE) { state.get(tmpMatrix); RectF imageRect = tmpRectF; imageRect.set(0, 0, settings.getImageW(), settings.getImageH()); tmpMatrix.mapRect(imageRect); tmpPointArr[0] = tmpPointArr[1] = 0f; tmpMatrix.mapPoints(tmpPointArr); bounds.offset(tmpPointArr[0] - imageRect.left, tmpPointArr[1] - imageRect.top); } return this; }
Example 20
Source File: DocPageView.java From Mupdf with Apache License 2.0 | 4 votes |
public void draw(Canvas canvas) { // various dimensions and colors int size = 28; int hightlightBorderWidth = Math.max(1, pageToView(5)); int highlightBorderColor = Color.parseColor("#0080FF"); int highlightColor = Color.parseColor("#0080FF"); int highlightAlpha = 50; int bubbleBorderColor = Color.parseColor("#000000"); int bubbleBorderWidth = Math.max(1, pageToView(1)); int bubbleColor = Color.parseColor("#FFFF00"); int bubbleAlpha = 128; int cornerRadius = pageToView(4); // get the rect in view coordinates PointF ul = new PointF(mPoint.x, mPoint.y-size); PointF dr = new PointF(mPoint.x+size, mPoint.y); pageToView(ul, ul); pageToView(dr, dr); Rect rt = new Rect((int)ul.x, (int)ul.y, (int)dr.x, (int)dr.y); if (isSelected()) { // paint a selection highligt Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setAlpha(255); paint.setColor(highlightBorderColor); paint.setStrokeWidth(hightlightBorderWidth); canvas.drawRect(rt, paint); paint.setStyle(Paint.Style.FILL); paint.setColor(highlightColor); paint.setAlpha(highlightAlpha); canvas.drawRect(rt, paint); } // create a path for the bubble Path path = new Path(); path.moveTo(rt.left, rt.bottom-cornerRadius); path.lineTo(rt.left, rt.top+cornerRadius); final RectF oval = new RectF(); oval.set(rt.left, rt.top, rt.left+2*cornerRadius, rt.top+2*cornerRadius); path.arcTo(oval, 180, 90); path.lineTo(rt.right-cornerRadius, rt.top); oval.set(rt.right-2*cornerRadius, rt.top, rt.right, rt.top+2*cornerRadius); path.arcTo(oval, 270, 90); path.lineTo(rt.right, rt.bottom-cornerRadius); oval.set(rt.right-2*cornerRadius, rt.bottom-2*cornerRadius, rt.right, rt.bottom); path.arcTo(oval, 0, 90); path.lineTo(rt.left+3*cornerRadius, rt.bottom); path.lineTo(rt.left, rt.bottom+rt.height()/3); path.lineTo(rt.left+cornerRadius, rt.bottom); oval.set(rt.left, rt.bottom-2*cornerRadius, rt.left+2*cornerRadius, rt.bottom); path.arcTo(oval, 90, 90); path.lineTo(rt.left, rt.bottom-cornerRadius); path.close(); // paint the bubble interior Paint p1 = new Paint(); p1.setStyle(Paint.Style.FILL); p1.setColor(bubbleColor); p1.setAlpha(bubbleAlpha); canvas.drawPath(path, p1); // paint the bubble border Paint p2 = new Paint(); p2.setStyle(Paint.Style.STROKE); p2.setColor(bubbleBorderColor); p2.setStrokeWidth(bubbleBorderWidth); canvas.drawPath(path, p2); }