List of usage examples for android.graphics RectF RectF
public RectF()
From source file:me.uucky.colorpicker.internal.ColorView.java
public ColorView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorView); mRect = new RectF(); mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); final Bitmap bitmap = Utils .getAlphaPatternBitmap(Math.round(getResources().getDisplayMetrics().density * 8)); mAlphaPatternPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mAlphaPatternPaint.setShader(new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT)); mRadius = a.getDimension(R.styleable.ColorView_cp_cornerRadius, 0); ViewCompat.setElevation(this, a.getDimension(R.styleable.ColorView_cp_elevation, 0)); a.recycle();/* ww w . j av a 2s. co m*/ if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { Internal.setOutlineProvider(this); } }
From source file:com.manning.androidhacks.hack007.view.Rectangle.java
public Rectangle(Context context, DrawView drawView) { super(context); mDrawView = drawView;//from w ww . j a va2s . c o m mInnerPaint = new Paint(); mDrawRect = new RectF(); /* Red is default */ mInnerPaint.setARGB(ALPHA, 255, 0, 0); mInnerPaint.setAntiAlias(true); }
From source file:cn.bingoogolapple.refreshlayout.BGAStickinessRefreshView.java
private void initBounds() { mTopBound = new RectF(); mBottomBound = new RectF(); mRotateDrawableBound = new Rect(); mCenterPoint = new Point(); }
From source file:android.support.design.widget.ShadowDrawableWrapper.java
public ShadowDrawableWrapper(Context context, Drawable content, float radius, float shadowSize, float maxShadowSize) { super(content); mShadowStartColor = ContextCompat.getColor(context, R.color.design_fab_shadow_start_color); mShadowMiddleColor = ContextCompat.getColor(context, R.color.design_fab_shadow_mid_color); mShadowEndColor = ContextCompat.getColor(context, R.color.design_fab_shadow_end_color); mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); mCornerShadowPaint.setStyle(Paint.Style.FILL); mCornerRadius = Math.round(radius); mContentBounds = new RectF(); mEdgeShadowPaint = new Paint(mCornerShadowPaint); mEdgeShadowPaint.setAntiAlias(false); setShadowSize(shadowSize, maxShadowSize); }
From source file:lib.picturechooser.crop.CropFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.crop, null); DisplayMetrics metrics = new DisplayMetrics(); ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getMetrics(metrics);//from ww w .ja v a2 s. c o m int availableHeight = metrics.heightPixels; int availableWidth = metrics.widthPixels; TypedValue tv = new TypedValue(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) availableHeight -= TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) availableHeight -= getResources().getDimensionPixelSize(resourceId); final float[] imgDetails = new float[3]; ImageView iv = (ImageView) v.findViewById(R.id.image); iv.setImageBitmap(ImageLoader.decode(getArguments().getString("imgPath"), availableWidth, availableHeight, imgDetails)); float imageViewWidth = imgDetails[0]; float imageViewHeight = imgDetails[1]; if (imageViewWidth > availableWidth || imageViewHeight > availableHeight) { while (imageViewWidth > availableWidth || imageViewHeight > availableHeight) { imageViewWidth *= 0.99f; imageViewHeight *= 0.99f; } } else { while (imageViewWidth < availableWidth && imageViewHeight < availableHeight) { imageViewWidth *= 1.01f; imageViewHeight *= 1.01f; } } float spareWidth = availableWidth - imageViewWidth; float spareHeight = availableHeight - imageViewHeight; final CropView cv = (CropView) v.findViewById(R.id.crop); final RectF imagePosition = new RectF(); imagePosition.left = spareWidth / 2; imagePosition.top = spareHeight / 2; imagePosition.right = imagePosition.left + imageViewWidth; imagePosition.bottom = imagePosition.top + imageViewHeight; cv.setImagePosition(imagePosition); cv.setScale(imgDetails[0] / imagePosition.width()); cv.setAspect(getArguments().getFloat("aspect", 0)); v.findViewById(R.id.save).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { new SaveTask((SelectPictureActivity) getActivity(), cv, imagePosition) .execute(getArguments().getString("imgPath")); } }); return v; }
From source file:de.j4velin.picturechooser.crop.CropFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.crop, null); DisplayMetrics metrics = new DisplayMetrics(); ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getMetrics(metrics);//from www. j a v a 2s . co m int availableHeight = metrics.heightPixels; int availableWidth = metrics.widthPixels; TypedValue tv = new TypedValue(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) availableHeight -= TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) availableHeight -= getResources().getDimensionPixelSize(resourceId); final float[] imgDetails = new float[3]; ImageView iv = (ImageView) v.findViewById(R.id.image); iv.setImageBitmap(ImageLoader.decode(getArguments().getString("imgPath"), availableWidth, availableHeight, imgDetails)); float imageViewWidth = imgDetails[0]; float imageViewHeight = imgDetails[1]; if (imageViewWidth > availableWidth || imageViewHeight > availableHeight) { while (imageViewWidth > availableWidth || imageViewHeight > availableHeight) { imageViewWidth *= 0.99f; imageViewHeight *= 0.99f; } } else { while (imageViewWidth < availableWidth && imageViewHeight < availableHeight) { imageViewWidth *= 1.01f; imageViewHeight *= 1.01f; } } float spareWidth = availableWidth - imageViewWidth; float spareHeight = availableHeight - imageViewHeight; final CropView cv = (CropView) v.findViewById(R.id.crop); final RectF imagePosition = new RectF(); imagePosition.left = spareWidth / 2; imagePosition.top = spareHeight / 2; imagePosition.right = imagePosition.left + imageViewWidth; imagePosition.bottom = imagePosition.top + imageViewHeight; cv.setImagePosition(imagePosition); cv.setScale(imgDetails[0] / imagePosition.width()); cv.setAspect(getArguments().getFloat("aspect", 0)); v.findViewById(R.id.save).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { new SaveTask((Main) getActivity(), cv, imagePosition).execute(getArguments().getString("imgPath")); } }); return v; }
From source file:com.ceabie.EffectiveLib.EffectImageView.java
@Override protected void onDraw(Canvas canvas) { if (mEffectDrawable == null || mEffectDrawable.getOpacity() == PixelFormat.TRANSPARENT // ? || getDrawable() == null) {/*w w w . j a va 2 s . c o m*/ super.onDraw(canvas); return; } if (mRectF == null) { mRectF = new RectF(); } mRectF.left = 0; mRectF.top = 0; mRectF.right = getMeasuredWidth(); mRectF.bottom = getMeasuredHeight(); int saveBottom = 0; // if (!mHardware) { saveBottom = canvas.saveLayer(mRectF, null, Canvas.CLIP_TO_LAYER_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG); } super.onDraw(canvas); mPaint.setXfermode(mXfermodeDstIn); int saveCount = canvas.saveLayer(mRectF, mPaint, Canvas.CLIP_TO_LAYER_SAVE_FLAG); mPaint.setXfermode(null); mEffectDrawable.draw(canvas); canvas.restoreToCount(saveCount); if (!mHardware) { canvas.restoreToCount(saveBottom); } }
From source file:me.lizheng.deckview.helpers.FakeShadowDrawable.java
public FakeShadowDrawable(Context context, DeckViewConfig config) { mShadowStartColor = ContextCompat.getColor(context, R.color.fake_shadow_start_color); mShadowEndColor = ContextCompat.getColor(context, R.color.fake_shadow_end_color); mInsetShadow = context.getResources().getDimension(R.dimen.fake_shadow_inset); setShadowSize(context.getResources().getDimensionPixelSize(R.dimen.fake_shadow_size), context.getResources().getDimensionPixelSize(R.dimen.fake_shadow_size)); mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); mCornerShadowPaint.setStyle(Paint.Style.FILL); mCornerShadowPaint.setDither(true);//from www . j a va 2 s . c o m mCornerRadius = config.taskViewRoundedCornerRadiusPx; mCardBounds = new RectF(); mEdgeShadowPaint = new Paint(mCornerShadowPaint); }
From source file:com.wytiger.common.widget.SlideSwitch.java
public void initDrawingVal() { int width = getMeasuredWidth(); int height = getMeasuredHeight(); backCircleRect = new RectF(); frontCircleRect = new RectF(); frontRect = new Rect(); backRect = new Rect(0, 0, width, height); min_left = RIM_SIZE;//w w w.j a va 2 s .c o m if (mShape == SHAPE_RECT) max_left = width / 2; else max_left = width - (height - 2 * RIM_SIZE) - RIM_SIZE; if (isOpen) { frontRect_left = max_left; alpha = 255; } else { frontRect_left = RIM_SIZE; alpha = 0; } frontRect_left_begin = frontRect_left; }
From source file:com.android.tabletcustomui.views.LeftCircleContainer.java
private void addCircle(int position, final int value, float diff, double ratio) { final int radius = value / 2; final RectF mOval = new RectF(); mOval.set(0 + diff, 0 + diff, value - diff, value - diff); final Paint mPaintClip = new Paint(); mPaintClip.setStyle(Paint.Style.FILL); mPaintClip.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.OVERLAY)); mPaintClip.setAntiAlias(true);/* w w w .j a v a 2s . co m*/ final PointF pointF = new PointF(mOval.centerX(), mOval.centerY()); final Path clipPath = new Path(); clipPath.addCircle(pointF.x, pointF.y, (float) (radius * ratio), Path.Direction.CW); View circleView; if (position == 0) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 330, 10, true, mPaintClip); canvas.drawArc(mOval, 342, 20, true, mPaintClip); canvas.drawArc(mOval, 4, 10, true, mPaintClip); canvas.drawArc(mOval, 240, 10, true, mPaintClip); canvas.drawArc(mOval, 252, 20, true, mPaintClip); canvas.drawArc(mOval, 275, 10, true, mPaintClip); canvas.drawArc(mOval, 150, 10, true, mPaintClip); canvas.drawArc(mOval, 162, 20, true, mPaintClip); canvas.drawArc(mOval, 185, 10, true, mPaintClip); canvas.drawArc(mOval, 60, 10, true, mPaintClip); canvas.drawArc(mOval, 72, 20, true, mPaintClip); canvas.drawArc(mOval, 95, 10, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 1) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_dark_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawCircle(pointF.x, pointF.y, radius, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 2) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 55, 190, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 3) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 240, 190, true, mPaintClip); canvas.drawArc(mOval, 80, 150, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 4) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 335, 150, true, mPaintClip); canvas.drawArc(mOval, 140, 180, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 5) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_grey)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 330, 150, true, mPaintClip); canvas.drawArc(mOval, 140, 150, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 6) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_purple_color)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 290, 5, true, mPaintClip); canvas.drawArc(mOval, 297, 20, true, mPaintClip); canvas.drawArc(mOval, 319, 20, true, mPaintClip); canvas.drawArc(mOval, 60, 15, true, mPaintClip); canvas.drawArc(mOval, 77, 8, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 7) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_dark_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 160, 10, true, mPaintClip); canvas.drawArc(mOval, 172, 30, true, mPaintClip); canvas.drawArc(mOval, 204, 30, true, mPaintClip); canvas.drawArc(mOval, 236, 10, true, mPaintClip); canvas.drawArc(mOval, 20, 20, true, mPaintClip); canvas.drawArc(mOval, 42, 8, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateAntiClockWise(circleView); } }