List of usage examples for android.graphics RectF RectF
public RectF(float left, float top, float right, float bottom)
From source file:org.mozilla.gecko.gfx.RectUtils.java
public static RectF scale(RectF rect, float scale) { float x = rect.left * scale; float y = rect.top * scale; return new RectF(x, y, x + (rect.width() * scale), y + (rect.height() * scale)); }
From source file:org.mozilla.gecko.gfx.ViewportMetrics.java
public ViewportMetrics() { DisplayMetrics metrics = new DisplayMetrics(); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); mPageSize = new FloatSize(metrics.widthPixels, metrics.heightPixels); mViewportRect = new RectF(0, 0, metrics.widthPixels, metrics.heightPixels); mViewportOffset = new PointF(0, 0); mZoomFactor = 1.0f;/*from w w w. j a va 2 s. c om*/ mViewportBias = new PointF(0.0f, 0.0f); }
From source file:com.king.android.common.widget.badge.BGADragBadgeView.java
private void drawTextBadge(Canvas canvas) { // ? mBadgePaint.setColor(mBadgeViewHelper.getBadgeBgColor()); // //from w w w .j a v a 2 s. c o m canvas.drawRoundRect( new RectF(mStartX, mStartY, mStartX + mBadgeViewHelper.getBadgeRectF().width(), mStartY + mBadgeViewHelper.getBadgeRectF().height()), mBadgeViewHelper.getBadgeRectF().height() / 2, mBadgeViewHelper.getBadgeRectF().height() / 2, mBadgePaint); // mBadgePaint.setColor(mBadgeViewHelper.getBadgeTextColor()); float x = mStartX + mBadgeViewHelper.getBadgeRectF().width() / 2; // ?y??? float y = mStartY + mBadgeViewHelper.getBadgeRectF().height() - mBadgeViewHelper.getBadgePadding(); // String badgeText = mBadgeViewHelper.getBadgeText() == null ? "" : mBadgeViewHelper.getBadgeText(); canvas.drawText(badgeText, x, y, mBadgePaint); }
From source file:com.google.android.apps.iosched.ui.VendorDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vendor_detail); mName = (TextView) findViewById(R.id.vendor_name); mLocation = (TextView) findViewById(R.id.vendor_location); mStarred = (CompoundButton) findViewById(R.id.star_button); mStarred.setFocusable(true);//from w w w .jav a2s . c o m mStarred.setClickable(true); // Larger target triggers star toggle final View starParent = findViewById(R.id.list_item_vendor); FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f)); mLogo = (ImageView) findViewById(R.id.vendor_logo); mUrl = (TextView) findViewById(R.id.vendor_url); mDesc = (TextView) findViewById(R.id.vendor_desc); mProductDesc = (TextView) findViewById(R.id.vendor_product_desc); final Intent intent = getIntent(); mVendorUri = intent.getData(); // Start background query to load vendor details mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); mHandler.startQuery(mVendorUri, VendorsQuery.PROJECTION); }
From source file:com.example.accessibility.FeedbackClickView.java
public FeedbackClickView(Context context) { super(context); paintWhite.setColor(Color.WHITE); paintWhite.setStrokeWidth(4);/*from w w w .j a v a2 s . co m*/ paintWhite.setARGB(128, 255, 255, 255); paintWhite.setStyle(Paint.Style.FILL_AND_STROKE); paintWhite.setAntiAlias(true); paintBlack.setStrokeWidth(4); paintBlack.setARGB(128, 0, 0, 0); paintBlack.setStyle(Paint.Style.FILL_AND_STROKE); paintBlack.setAntiAlias(true); mGreen = new Paint(Paint.ANTI_ALIAS_FLAG); mGreen.setARGB(128, 0, 255, 0); mGreen.setStyle(Style.FILL); mYellow.setStyle(Style.FILL_AND_STROKE); mYellow.setStrokeWidth(3); mYellow.setColor(Color.YELLOW); mBlack.setStyle(Style.FILL_AND_STROKE); mBlack.setStrokeWidth(3); mBlack.setColor(Color.BLACK); mButton = "clear"; oval = new RectF(50, 50, 150, 150); deg = 0; }
From source file:com.mikelau.croperino.HighlightView.java
protected void draw(Canvas canvas) { if (mHidden) { return;// www. j a v a 2 s .c om } Path path = new Path(); if (!hasFocus()) { mOutlinePaint.setColor(0xFF000000); canvas.drawRect(mDrawRect, mOutlinePaint); } else { Rect viewDrawingRect = new Rect(); mContext.getDrawingRect(viewDrawingRect); if (mCircle) { canvas.save(); float width = mDrawRect.width(); float height = mDrawRect.height(); path.addCircle(mDrawRect.left + (width / 2), mDrawRect.top + (height / 2), width / 2, Path.Direction.CW); mOutlinePaint.setColor(0xFFEF04D6); canvas.clipPath(path, Region.Op.DIFFERENCE); canvas.drawRect(viewDrawingRect, hasFocus() ? mFocusPaint : mNoFocusPaint); canvas.restore(); } else if (mOvalo) { canvas.save(); RectF r = new RectF(mDrawRect.left, mDrawRect.top, mDrawRect.right, mDrawRect.bottom); path.addOval(r, Path.Direction.CW); mOutlinePaint.setColor(0xFFEF04D6); canvas.clipPath(path, Region.Op.DIFFERENCE); canvas.drawRect(viewDrawingRect, hasFocus() ? mFocusPaint : mNoFocusPaint); canvas.restore(); } else { Rect topRect = new Rect(viewDrawingRect.left, viewDrawingRect.top, viewDrawingRect.right, mDrawRect.top); if (topRect.width() > 0 && topRect.height() > 0) { canvas.drawRect(topRect, hasFocus() ? mFocusPaint : mNoFocusPaint); } Rect bottomRect = new Rect(viewDrawingRect.left, mDrawRect.bottom, viewDrawingRect.right, viewDrawingRect.bottom); if (bottomRect.width() > 0 && bottomRect.height() > 0) { canvas.drawRect(bottomRect, hasFocus() ? mFocusPaint : mNoFocusPaint); } Rect leftRect = new Rect(viewDrawingRect.left, topRect.bottom, mDrawRect.left, bottomRect.top); if (leftRect.width() > 0 && leftRect.height() > 0) { canvas.drawRect(leftRect, hasFocus() ? mFocusPaint : mNoFocusPaint); } Rect rightRect = new Rect(mDrawRect.right, topRect.bottom, viewDrawingRect.right, bottomRect.top); if (rightRect.width() > 0 && rightRect.height() > 0) { canvas.drawRect(rightRect, hasFocus() ? mFocusPaint : mNoFocusPaint); } path.addRect(new RectF(mDrawRect), Path.Direction.CW); mOutlinePaint.setColor(0xFFFF8A00); } canvas.drawPath(path, mOutlinePaint); if (mMode == ModifyMode.Grow) { if (mCircle) { int width = mResizeDrawableDiagonal.getIntrinsicWidth(); int height = mResizeDrawableDiagonal.getIntrinsicHeight(); int d = (int) Math.round(Math.cos(/*45deg*/Math.PI / 4D) * (mDrawRect.width() / 2D)); int x = mDrawRect.left + (mDrawRect.width() / 2) + d - width / 2; int y = mDrawRect.top + (mDrawRect.height() / 2) - d - height / 2; mResizeDrawableDiagonal.setBounds(x, y, x + mResizeDrawableDiagonal.getIntrinsicWidth(), y + mResizeDrawableDiagonal.getIntrinsicHeight()); mResizeDrawableDiagonal.draw(canvas); } else { int left = mDrawRect.left + 1; int right = mDrawRect.right + 1; int top = mDrawRect.top + 4; int bottom = mDrawRect.bottom + 3; int widthWidth = mResizeDrawableWidth.getIntrinsicWidth() / 2; int widthHeight = mResizeDrawableWidth.getIntrinsicHeight() / 2; int heightHeight = mResizeDrawableHeight.getIntrinsicHeight() / 2; int heightWidth = mResizeDrawableHeight.getIntrinsicWidth() / 2; int xMiddle = mDrawRect.left + ((mDrawRect.right - mDrawRect.left) / 2); int yMiddle = mDrawRect.top + ((mDrawRect.bottom - mDrawRect.top) / 2); mResizeDrawableWidth.setBounds(left - widthWidth, yMiddle - widthHeight, left + widthWidth, yMiddle + widthHeight); mResizeDrawableWidth.draw(canvas); mResizeDrawableWidth.setBounds(right - widthWidth, yMiddle - widthHeight, right + widthWidth, yMiddle + widthHeight); mResizeDrawableWidth.draw(canvas); mResizeDrawableHeight.setBounds(xMiddle - heightWidth, top - heightHeight, xMiddle + heightWidth, top + heightHeight); mResizeDrawableHeight.draw(canvas); mResizeDrawableHeight.setBounds(xMiddle - heightWidth, bottom - heightHeight, xMiddle + heightWidth, bottom + heightHeight); mResizeDrawableHeight.draw(canvas); } } } }
From source file:com.qjay.android_widget.badge.BGADragBadgeView.java
private void drawTextBadge(Canvas canvas) { // /*from w w w. j av a2 s .c o m*/ mBadgePaint.setColor(mBadgeViewHelper.getBadgeBgColor()); // canvas.drawRoundRect( new RectF(mStartX, mStartY, mStartX + mBadgeViewHelper.getBadgeRectF().width(), mStartY + mBadgeViewHelper.getBadgeRectF().height()), mBadgeViewHelper.getBadgeRectF().height() / 2, mBadgeViewHelper.getBadgeRectF().height() / 2, mBadgePaint); // mBadgePaint.setColor(mBadgeViewHelper.getBadgeTextColor()); float x = mStartX + mBadgeViewHelper.getBadgeRectF().width() / 2; // ?y? float y = mStartY + mBadgeViewHelper.getBadgeRectF().height() - mBadgeViewHelper.getBadgePadding(); // String badgeText = mBadgeViewHelper.getBadgeText() == null ? "" : mBadgeViewHelper.getBadgeText(); canvas.drawText(badgeText, x, y, mBadgePaint); }
From source file:com.subroto.fragmenttransactions.FractionalFrameLayout.java
public void setYFraction(float yFraction) { mYFraction = yFraction;// ww w . j a v a 2 s .c o m setY((mScreenHeight > 0) ? (mScreenHeight - yFraction * mScreenHeight) : 0); mCurrentViewport = new RectF(AXIS_X_MIN, AXIS_Y_MIN, AXIS_X_MAX, yFraction); }
From source file:com.goliathonline.android.kegbot.ui.VendorDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_vendor_detail, null); mName = (TextView) mRootView.findViewById(R.id.vendor_name); mStarred = (CompoundButton) mRootView.findViewById(R.id.star_button); mStarred.setFocusable(true);/*from w w w .j ava2s . c o m*/ mStarred.setClickable(true); // Larger target triggers star toggle final View starParent = mRootView.findViewById(R.id.header_vendor); FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f)); mLogo = (ImageView) mRootView.findViewById(R.id.vendor_logo); mUrl = (TextView) mRootView.findViewById(R.id.vendor_url); mDesc = (TextView) mRootView.findViewById(R.id.vendor_desc); mProductDesc = (TextView) mRootView.findViewById(R.id.vendor_product_desc); return mRootView; }
From source file:com.myhexaville.iconanimations.gooey_fab.GooeyFabCompatImpl.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); RectF gooeyPart = new RectF(0, mCenterY - getArcAbsolute(), mWidth, mCenterY + getArcAbsolute()); RectF backgroundCircle = new RectF(0, mCenterY - getFabWidth() / 2, mWidth, mCenterY + getFabWidth() / 2); canvas.drawArc(gooeyPart, 0, mIsLargeFab ? -180 : 180, false, mPaint); canvas.drawArc(backgroundCircle, 0, 360, false, mPaint); }