android.graphics.RectF Java Examples

The following examples show how to use android.graphics.RectF. 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 Project: document-viewer   Author: SufficientlySecure   File: SearchModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
public RectF moveToNext(final ProgressCallback callback) {
    final IViewController ctrl = base.getDocumentController();
    final int firstVisiblePage = ctrl.getFirstVisiblePage();
    final int lastVisiblePage = ctrl.getLastVisiblePage();

    if (currentPage == null) {
        return searchFirstFrom(firstVisiblePage, callback);
    }

    final Matches m = getMatches(currentPage.index.docIndex);
    if (m == null) {
        return searchFirstFrom(currentPage.index.viewIndex, callback);
    }

    if (firstVisiblePage <= currentPage.index.viewIndex && currentPage.index.viewIndex <= lastVisiblePage) {
        currentMatchIndex++;
        final List<? extends RectF> mm = m.getMatches();
        if (0 <= currentMatchIndex && currentMatchIndex < LengthUtils.length(mm)) {
            return mm.get(currentMatchIndex);
        } else {
            return searchFirstFrom(currentPage.index.viewIndex + 1, callback);
        }
    } else {
        return searchFirstFrom(firstVisiblePage, callback);
    }
}
 
Example #2
Source Project: ReadMark   Author: chengkun123   File: KLetter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initConfig(int x, int y) {
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mStrokeWidth);
    mPaint.setAntiAlias(true);
    mPaint.setColor(Config.WHITE);
    mPaint.setStrokeCap(Paint.Cap.SQUARE);

    mRectF = new RectF(x - MAX_RADIUS_CIRCLE
            , y - MAX_RADIUS_CIRCLE - MAX_RADIUS_CIRCLE / 2
            , x + MAX_RADIUS_CIRCLE
            , y + MAX_RADIUS_CIRCLE / 2);

    mFirPoint = new Point(x, y - 2 * MAX_RADIUS_CIRCLE);
    mSecPoint = new Point(mFirPoint);
    mThiPoint = new Point(x, y + MAX_RADIUS_CIRCLE / 2 + MAX_RADIUS_CIRCLE / 4);
    mFourPoint = new Point(mThiPoint);
    mFifPoint = new Point(mThiPoint);
}
 
Example #3
Source Project: chatui   Author: stridercheng   File: BubbleDrawable.java    License: Apache License 2.0 6 votes vote down vote up
private void setUpLeftPath(RectF rect, Path path){

        path.moveTo(mArrowWidth + rect.left + mAngle, rect.top);
        path.lineTo(rect.width() - mAngle, rect.top);
        path.arcTo(new RectF(rect.right - mAngle , rect.top, rect.right,
                mAngle + rect.top), 270, 90);
        path.lineTo(rect.right, rect.bottom - mAngle);
        path.arcTo(new RectF(rect.right - mAngle , rect.bottom - mAngle,
                rect.right, rect.bottom), 0, 90);
        path.lineTo(rect.left + mArrowWidth + mAngle, rect.bottom);
        path.arcTo(new RectF(rect.left + mArrowWidth, rect.bottom - mAngle ,
                mAngle + rect.left + mArrowWidth, rect.bottom), 90, 90);
        path.lineTo(rect.left + mArrowWidth,  mArrowHeight + mArrowPosition);
        path.lineTo(rect.left, mArrowPosition + mArrowHeight / 2);
        path.lineTo(rect.left + mArrowWidth, mArrowPosition);
        path.lineTo(rect.left + mArrowWidth, rect.top + mAngle);
        path.arcTo(new RectF(rect.left + mArrowWidth, rect.top, mAngle
                + rect.left + mArrowWidth, mAngle + rect.top), 180, 90);
        path.close();
    }
 
Example #4
Source Project: codeexamples-android   Author: vogellacompany   File: RoundImageView.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void createFramedPhotoBorder(int size) {
	Drawable imageDrawable = (image != null) ? new BitmapDrawable(
			getResources(), image) : placeholder;

	Bitmap output = Bitmap
			.createBitmap(size, size, Bitmap.Config.ARGB_8888);
	Canvas canvas = new Canvas(output);

	RectF outerRect = new RectF(0, 0, size, size);
	float cornerRadius = size / 20f;

	Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setColor(Color.RED);
	canvas.drawRoundRect(outerRect, cornerRadius, cornerRadius, paint);

	paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
	imageDrawable.setBounds(0, 0, size, size);

	// Save the layer to apply the paint
	canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
	imageDrawable.draw(canvas);
	canvas.restore();
	framedPhoto = output;
}
 
Example #5
Source Project: PinchToZoom   Author: martinwithaar   File: ImageViewUtils.java    License: MIT License 6 votes vote down vote up
/**
 *
 * @param imageView
 * @param width
 * @param height
 */
public static final void updateImageViewMatrix(ImageView imageView, float width, float height) {
    Drawable drawable = imageView.getDrawable();
    if(drawable == null) {
        throw new NullPointerException("ImageView drawable is null");
    }
    Matrix matrix = imageView.getImageMatrix();
    if(!matrix.isIdentity()) {
        float[] values = new float[9];
        matrix.getValues(values);

        RectF src = new RectF();
        src.left = 0;
        src.top = 0;
        src.right = width;
        src.bottom = height;

        RectF dst = new RectF();
        dst.left = values[Matrix.MTRANS_X];
        dst.top = values[Matrix.MTRANS_Y];
        dst.right = dst.left + (drawable.getIntrinsicWidth() * values[Matrix.MSCALE_X]);
        dst.bottom = dst.top + (drawable.getIntrinsicHeight() * values[Matrix.MSCALE_Y]);

        matrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
    }
}
 
Example #6
Source Project: OXChart   Author: openXu   File: OilTableLine.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    float size = Math.min(w, h) - tableWidth * 2;
    //油表的位置方框
    mTableRectF = new RectF(0, 0, size, size);
    mPath.reset();
    //在油表路径中增加一个从起始弧度
    mPath.addArc(mTableRectF, 60, 240);
    //计算路径的长度
    PathMeasure pathMeasure = new PathMeasure(mPath, false);
    float length = pathMeasure.getLength();
    float step = length / 60;
    dashPathEffect = new DashPathEffect(new float[]{step / 3, step * 2 / 3}, 0);

    float radius = size / 2;
    mColorShader = new SweepGradient(radius, radius,SWEEP_GRADIENT_COLORS,null);
    //设置指针的路径位置
    mPointerPath.reset();
    mPointerPath.moveTo(radius, radius - 20);
    mPointerPath.lineTo(radius, radius + 20);
    mPointerPath.lineTo(radius * 2 - tableWidth, radius);
    mPointerPath.close();
}
 
Example #7
Source Project: data-binding-sample   Author: sys1yagi   File: RoundedCornerTransformation.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap getRoundedCornerBitmap(Bitmap input,
        float cornerRadius, int w, int h) {

    Bitmap output = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, w, h);
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, cornerRadius, cornerRadius, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(input, 0, 0, paint);

    return output;
}
 
Example #8
Source Project: AdvancedMaterialDrawer   Author: madcyph3r   File: MaterialRippleLayoutNineOld.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void draw(Canvas canvas) {
    final boolean positionChanged = adapterPositionChanged();
    if (rippleOverlay) {
        if (!positionChanged) {
            rippleBackground.draw(canvas);
        }
        super.draw(canvas);
        if (!positionChanged) {
            if (rippleRoundedCorners != 0) {
                Path clipPath = new Path();
                RectF rect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
                clipPath.addRoundRect(rect, rippleRoundedCorners, rippleRoundedCorners, Path.Direction.CW);
                canvas.clipPath(clipPath);
            }
            canvas.drawCircle(currentCoords.x, currentCoords.y, radius, paint);
        }
    } else {
        if (!positionChanged) {
            rippleBackground.draw(canvas);
            canvas.drawCircle(currentCoords.x, currentCoords.y, radius, paint);
        }
        super.draw(canvas);
    }
}
 
Example #9
Source Project: fritz-examples   Author: fritzlabs   File: CameraConnectionFragment.java    License: MIT License 6 votes vote down vote up
/**
 * Configures the necessary {@link android.graphics.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`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
    final Activity activity = getActivity();
    if (null == textureView || null == previewSize || 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, previewSize.getHeight(), previewSize.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 / previewSize.getHeight(),
                        (float) viewWidth / previewSize.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);
    }
    textureView.setTransform(matrix);
}
 
Example #10
Source Project: Rey-MusicPlayer   Author: reyanshmishra   File: MusicUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    if (bitmap == null) {
        bitmap = BitmapFactory.decodeResource(Common.getInstance().getResources(),
                R.drawable.ic_placeholder);
    }


    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
Example #11
Source Project: MaterialTapTargetPrompt   Author: sjwall   File: MaterialTapTargetPrompt.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Update the icon drawable position or target render view position.
 */
void updateIconPosition()
{
    mView.mIconDrawable = mView.mPromptOptions.getIconDrawable();
    if (mView.mIconDrawable != null)
    {
        final RectF mFocalBounds = mView.mPromptOptions.getPromptFocal().getBounds();
        mView.mIconDrawableLeft = mFocalBounds.centerX()
                - (mView.mIconDrawable.getIntrinsicWidth() / 2);
        mView.mIconDrawableTop = mFocalBounds.centerY()
                - (mView.mIconDrawable.getIntrinsicHeight() / 2);
    }
    else if (mView.mTargetRenderView != null)
    {
        final int[] viewPosition = new int[2];
        mView.getLocationInWindow(viewPosition);
        final int[] targetPosition = new int[2];
        mView.mTargetRenderView.getLocationInWindow(targetPosition);

        mView.mIconDrawableLeft = targetPosition[0] - viewPosition[0] - mView.mTargetRenderView.getScrollX();
        mView.mIconDrawableTop = targetPosition[1] - viewPosition[1] - mView.mTargetRenderView.getScrollY();
    }
}
 
Example #12
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: OC_Numberlines_S3.java    License: Apache License 2.0 6 votes vote down vote up
public void loadLine(int num,boolean clockwise)
{
    int rocknum = num;
    if(rocknum == 0)
        rocknum = 1;
    PointF position1 = OB_Maths.locationForRect(0.5f,0.01f,objectDict.get(String.format("rock%d", rocknum )).frame());
    PointF position2 = OB_Maths.locationForRect(0.5f,0.01f,objectDict.get(String.format("rock%d", rocknum+1 )).frame());

    OBPath curveLine = new OBPath();
    Path path = new Path();
    float radius = Math.abs(position1.x -position2.x)/2.0f;

    path.addArc(new RectF(position1.x,position1.y-radius,position2.x,position1.y+radius),clockwise ? 180 : 0, clockwise ? 180 : -180);
    curveLine.setPath(path);
    curveLine.sizeToBoundingBox();
    if(num == 0)
        curveLine.setRight ( curveLine.right()-curveLine.width());
    curveLine.setLineWidth((float)Math.ceil(applyGraphicScale(6)));
    curveLine.setStrokeColor( clockwise ? OBUtils.colorFromRGBString("255,252,0") : OBUtils.colorFromRGBString("255,83,0"));
    curveLine.setZPosition(0.8f);
    curveLine.hide();
    attachControl(curveLine);
    curveLine.sizeToBoundingBoxIncludingStroke();

    objectDict.put(String.format("line_%d_%d",clockwise ? 1 : 2, num),curveLine);
}
 
Example #13
Source Project: android-chromium   Author: kevin-smets   File: BookmarkUtils.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Use touch-icon or higher-resolution favicon and round the corners.
 * @param context    Context used to get resources.
 * @param touchIcon  Touch icon bitmap.
 * @param canvas     Canvas that holds the touch icon.
 */
private static void drawTouchIconToCanvas(
        Context context, Bitmap touchIcon, Canvas canvas) {
    Rect iconBounds = new Rect(0, 0, canvas.getWidth(), canvas.getHeight());
    Rect src = new Rect(0, 0, touchIcon.getWidth(), touchIcon.getHeight());
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setFilterBitmap(true);
    canvas.drawBitmap(touchIcon, src, iconBounds, paint);
    // Convert dp to px.
    int borderRadii = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            TOUCHICON_BORDER_RADII, context.getResources().getDisplayMetrics());
    Path path = new Path();
    path.setFillType(Path.FillType.INVERSE_WINDING);
    RectF rect = new RectF(iconBounds);
    rect.inset(INSET_DIMENSION_FOR_TOUCHICON, INSET_DIMENSION_FOR_TOUCHICON);
    path.addRoundRect(rect, borderRadii, borderRadii, Path.Direction.CW);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    canvas.drawPath(path, paint);
}
 
Example #14
Source Project: rings   Author: lalongooo   File: Rings.java    License: Apache License 2.0 6 votes vote down vote up
private void initPainters() {
    // Ring Rectangle objects
    ringOverall = new RectF();
    ringInnerThird = new RectF();
    ringInnerSecond = new RectF();
    ringInnerFirst = new RectF();

    // Init rectangles used by texts
    rectOverallText = new Rect();
    rectInnerThirdText = new Rect();
    rectInnerSecondText = new Rect();
    rectInnerFirstText = new Rect();
    // Auxiliary rect to get the width size used by text
    auxRect = new Rect();

    // Ring Paint
    ringPaint = new Paint();
    ringPaint.setAntiAlias(true);
    ringPaint.setStyle(Paint.Style.STROKE);
    ringPaint.setStrokeCap(Paint.Cap.ROUND);

    // Text Paint
    textPaint = new TextPaint();
    textPaint.setTextSize(textSize);
    textPaint.setAntiAlias(true);
}
 
Example #15
Source Project: ZzBeeLayout   Author: zhouzhuo810   File: SvgImageView.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap getBitmap(Context context, int width, int height, int svgRawResourceId) {
    Bitmap bitmap = Bitmap.createBitmap(width, height,
            Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.BLACK);

    if (svgRawResourceId > 0) {
        SVG svg = SVGParser.getSVGFromInputStream(
                context.getResources().openRawResource(svgRawResourceId), width, height);
        canvas.drawPicture(svg.getPicture());
    } else {
        canvas.drawRect(new RectF(0.0f, 0.0f, width, height), paint);
    }

    return bitmap;
}
 
Example #16
Source Project: fritz-examples   Author: fritzlabs   File: CameraConnectionFragment.java    License: MIT License 6 votes vote down vote up
/**
 * Configures the necessary {@link android.graphics.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`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
    final Activity activity = getActivity();
    if (null == textureView || null == previewSize || 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, previewSize.getHeight(), previewSize.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 / previewSize.getHeight(),
                        (float) viewWidth / previewSize.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);
    }
    textureView.setTransform(matrix);
}
 
Example #17
Source Project: Android-Image-Cropper   Author: ArthurHub   File: CropWindowMoveHandler.java    License: Apache License 2.0 6 votes vote down vote up
/** Center move only changes the position of the crop window without changing the size. */
private void moveCenter(
    RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapRadius) {
  float dx = x - rect.centerX();
  float dy = y - rect.centerY();
  if (rect.left + dx < 0
      || rect.right + dx > viewWidth
      || rect.left + dx < bounds.left
      || rect.right + dx > bounds.right) {
    dx /= 1.05f;
    mTouchOffset.x -= dx / 2;
  }
  if (rect.top + dy < 0
      || rect.bottom + dy > viewHeight
      || rect.top + dy < bounds.top
      || rect.bottom + dy > bounds.bottom) {
    dy /= 1.05f;
    mTouchOffset.y -= dy / 2;
  }
  rect.offset(dx, dy);
  snapEdgesToBounds(rect, bounds, snapRadius);
}
 
Example #18
Source Project: UltimateAndroid   Author: cymcsg   File: CropImageActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void makeDefault() {
    if (rotateBitmap == null) {
        return;
    }

    HighlightView hv = new HighlightView(imageView);
    final int width = rotateBitmap.getWidth();
    final int height = rotateBitmap.getHeight();

    Rect imageRect = new Rect(0, 0, width, height);

    // Make the default size about 4/5 of the width or height
    int cropWidth = Math.min(width, height) * 4 / 5;
    @SuppressWarnings("SuspiciousNameCombination")
    int cropHeight = cropWidth;

    if (aspectX != 0 && aspectY != 0) {
        if (aspectX > aspectY) {
            cropHeight = cropWidth * aspectY / aspectX;
        } else {
            cropWidth = cropHeight * aspectX / aspectY;
        }
    }

    int x = (width - cropWidth) / 2;
    int y = (height - cropHeight) / 2;

    RectF cropRect = new RectF(x, y, x + cropWidth, y + cropHeight);
    hv.setup(imageView.getUnrotatedMatrix(), imageRect, cropRect, aspectX != 0 && aspectY != 0);
    imageView.add(hv);
}
 
Example #19
Source Project: 365browser   Author: mogoweb   File: ContextualSearchPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(RectF viewport, RectF visibleViewport,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this,
            getSearchBarControl(),
            getPeekPromoControl(),
            getPromoControl(),
            getImageControl());

    return mSceneLayer;
}
 
Example #20
Source Project: QuranAndroid   Author: fekracomputers   File: HighlightImageView.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Function to init image view settings
 */
private void init() {
    this.context = super.getContext();
    mRects = new ArrayList<RectF>();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.argb(150, 146, 144, 248));
    setOnLongClickListener(this);
    setOnTouchListener(this);
}
 
Example #21
Source Project: imsdk-android   Author: qunarcorp   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
/**
 * Helper method that maps the supplied Matrix to the current Drawable
 *
 * @param matrix - Matrix to map Drawable against
 * @return RectF - Displayed Rectangle
 */
private RectF getDisplayRect(Matrix matrix) {
    Drawable d = mImageView.getDrawable();
    if (d != null) {
        mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
        matrix.mapRect(mDisplayRect);
        return mDisplayRect;
    }
    return null;
}
 
Example #22
Source Project: TelePlus-Android   Author: TelePlusDev   File: CropView.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CropView(Context context) {
    super(context);

    previousAreaRect = new RectF();
    initialAreaRect = new RectF();
    presentationMatrix = new Matrix();
    tempRect = new CropRectangle();
    tempMatrix = new Matrix();
    animating = false;

    backView = new View(context);
    backView.setBackgroundColor(0xff000000);
    backView.setVisibility(INVISIBLE);
    addView(backView);

    imageView = new ImageView(context);
    imageView.setDrawingCacheEnabled(true);
    imageView.setScaleType(ImageView.ScaleType.MATRIX);
    addView(imageView);

    detector = new CropGestureDetector(context);
    detector.setOnGestureListener(this);

    areaView = new CropAreaView(context);
    areaView.setListener(this);
    addView(areaView);
}
 
Example #23
Source Project: bcm-android   Author: bcmapp   File: CropRoundCornerTransform.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void drawDiagonalFromTopLeftRoundRect(Canvas canvas, Paint paint, float right,
                                              float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, margin + diameter), radius,
            radius, paint);
    canvas.drawRoundRect(new RectF(right - diameter, bottom - diameter, right, bottom), radius,
            radius, paint);
    canvas.drawRect(new RectF(margin, margin + radius, right - diameter, bottom), paint);
    canvas.drawRect(new RectF(margin + diameter, margin, right, bottom - radius), paint);
}
 
Example #24
Source Project: yolov3-android-tflite   Author: wics1224   File: Classifier.java    License: MIT License 5 votes vote down vote up
protected float box_intersection(RectF a, RectF b)
{
    float w = overlap((a.left + a.right) / 2, a.right - a.left,
            (b.left + b.right) / 2, b.right - b.left);
    float h = overlap((a.top + a.bottom) / 2, a.bottom - a.top,
            (b.top + b.bottom) / 2, b.bottom - b.top);
    if(w < 0 || h < 0) return 0;
    float area = w*h;
    return area;
}
 
Example #25
Source Project: pixate-freestyle-android   Author: Pixate   File: PXViewStyleAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RectF getBounds(Object styleable) {
    View view = (View) styleable;
    Rect r = new Rect();
    view.getDrawingRect(r);
    return new RectF(r);
}
 
Example #26
Source Project: GestureViews   Author: alexvasilkov   File: DebugOverlay.java    License: Apache License 2.0 5 votes vote down vote up
private static void drawRect(Canvas canvas, RectF rect, int color, float stroke) {
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(stroke);
    rectF.inset(0.5f * stroke, 0.5f * stroke);
    paint.setColor(color);
    canvas.drawRect(rect, paint);
}
 
Example #27
Source Project: MiBandDecompiled   Author: vishnudevk   File: b.java    License: Apache License 2.0 5 votes vote down vote up
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 #28
Source Project: CommentGallery   Author: ibosong   File: DefaultZoomableController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the image bounds, in view-absolute coordinates.
 */
@Override
public void setImageBounds(RectF imageBounds) {
    if (!imageBounds.equals(mImageBounds)) {
        mImageBounds.set(imageBounds);
        onTransformChanged();
    }
}
 
Example #29
Source Project: material-components-android   Author: material-components   File: CollapsingTextHelper.java    License: Apache License 2.0 5 votes vote down vote up
public CollapsingTextHelper(View view) {
  this.view = view;

  textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
  tmpPaint = new TextPaint(textPaint);

  collapsedBounds = new Rect();
  expandedBounds = new Rect();
  currentBounds = new RectF();
}
 
Example #30
Source Project: SpannableTextView   Author: milaptank   File: RoundedBackgroundSpan.java    License: MIT License 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
    RectF rect = new RectF(x, top, x + measureText(paint, text, start, end), bottom);
    paint.setColor(backgroundColor);
    canvas.drawRoundRect(rect, cornerRadius, cornerRadius, paint);
    paint.setColor(textColor);
    canvas.drawText(text, start, end, x, y, paint);
}