Example usage for android.graphics RectF RectF

List of usage examples for android.graphics RectF RectF

Introduction

In this page you can find the example usage for android.graphics RectF RectF.

Prototype

public RectF(float left, float top, float right, float bottom) 

Source Link

Document

Create a new rectangle with the specified coordinates.

Usage

From source file:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private void initLetterAndImageAttributes() {
    float[] letterProperty = this.measureText(this.letterPaint, DEFAULT_ONE_LETTER_MEASURE_WIDTH_CASE);
    this.letterSize = letterProperty[0];
    this.letterHeight = letterProperty[1];
    this.imageSectionRect = new RectF(0, 0, this.letterSize, this.letterSize);
    this.imageSectionBorderRadius = this.dp2px(DEFAULT_IMAGE_SECTION_BORDER_RADIUS);
    this.imageSectionCircleBorderRadius = this.dp2px(DEFAULT_IMAGE_SECTION_CIRCLE_BORDER_RADIUS);
}

From source file:nu.yona.app.customview.graph.TimeFrameGraph.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    RectF myRectum = new RectF(left, top, right, bottom);
    canvas.drawRect(myRectum, linePaint);

    //todraw text from height
    float heightDraw = bottom + (GraphUtils.MARGIN_TOP * scaleFactor);

    Bitmap moonBitmap = drawableToBitmap(ContextCompat.getDrawable(mContext, R.drawable.icon_moon));
    float bitmapWidth = moonBitmap.getWidth() / 2;
    //draw graphics of sun and moon
    canvas.drawBitmap(moonBitmap, mStartPoint - (5 * scaleFactor), bottom + (5 * scaleFactor), null);
    canvas.drawBitmap(drawableToBitmap(ContextCompat.getDrawable(mContext, R.drawable.icn_sun)),
            mMiddlePoint - bitmapWidth, bottom + (5 * scaleFactor), null);

    float textPoint = (mMiddlePoint / 2) / 2;
    canvas.drawText(mContext.getString(R.string.four_hours), textPoint, heightDraw, getFontStyle());
    float textPoint2 = textPoint * 2 + ((textPoint / 2));
    canvas.drawText(mContext.getString(R.string.eight_hours), textPoint2, heightDraw, getFontStyle());
    float textPoint3 = textPoint * 5;
    canvas.drawText(mContext.getString(R.string.sixteen_hours), textPoint3 - bitmapWidth, heightDraw,
            getFontStyle());//w  w w  .  j  av a  2  s. c o m
    float textPoint4 = textPoint * 6 + ((textPoint / 2));
    canvas.drawText(mContext.getString(R.string.twenty_hours), textPoint4 - bitmapWidth, heightDraw,
            getFontStyle());
    float textPoint5 = textPoint * 7 + ((textPoint / 2)) - (scaleFactor * 2);
    canvas.drawBitmap(drawableToBitmap(ContextCompat.getDrawable(mContext, R.drawable.icon_moon)), textPoint5,
            bottom + (5 * scaleFactor), null);

    for (GraphData graphData : graphDataList) {
        graphData.draw(canvas, top, bottom, endPoint);
    }
}

From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_detail, null);

    mTitle = (TextView) mRootView.findViewById(R.id.session_title);
    mSubtitle = (TextView) mRootView.findViewById(R.id.session_subtitle);

    // Larger target triggers plus one button
    mPlusOneButton = (PlusOneButton) mRootView.findViewById(R.id.plus_one_button);
    final View plusOneParent = mRootView.findViewById(R.id.header_session);
    FractionalTouchDelegate.setupDelegate(plusOneParent, mPlusOneButton, new RectF(0.6f, 0f, 1f, 1.0f));

    mAbstract = (TextView) mRootView.findViewById(R.id.session_abstract);
    mRequirements = (TextView) mRootView.findViewById(R.id.session_requirements);

    if (mVariableHeightHeader) {
        View headerView = mRootView.findViewById(R.id.header_session);
        ViewGroup.LayoutParams layoutParams = headerView.getLayoutParams();
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        headerView.setLayoutParams(layoutParams);
    }/*ww w. ja v  a 2 s .  c  o  m*/

    return mRootView;
}

From source file:com.lullabot.android.apps.iosched.ui.SessionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_detail, null);

    mTitle = (TextView) mRootView.findViewById(R.id.session_title);
    mSubtitle = (TextView) mRootView.findViewById(R.id.session_subtitle);
    mStarred = (CompoundButton) mRootView.findViewById(R.id.star_button);

    mStarred.setFocusable(true);//from   w ww  .j  a v  a2 s  . co m
    mStarred.setClickable(true);

    // Larger target triggers star toggle
    final View starParent = mRootView.findViewById(R.id.header_session);
    FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f));

    mAbstract = (TextView) mRootView.findViewById(R.id.session_abstract);

    setupSummaryTab();

    return mRootView;
}

From source file:com.fractview.ImageViewFragment.java

private void initImageMatrix() {
    // Set initMatrix + inverse to current view-size
    float vw = imageView.getWidth();
    float vh = imageView.getHeight();

    // Right after creation, this view might not 
    // be inside anything and therefore have size 0.
    if (vw <= 0 && vh <= 0)
        return; // do nothing.

    float bw = taskFragment.bitmap().getWidth();
    float bh = taskFragment.bitmap().getHeight();

    RectF viewRect = new RectF(0f, 0f, vw, vh);
    RectF bitmapRect;//  w ww  .  j a  v a  2s.c om

    if (vw > vh) {
        // if width of view is bigger, match longer side to it
        bitmapRect = new RectF(0f, 0f, Math.max(bw, bh), Math.min(bw, bh));
    } else {
        bitmapRect = new RectF(0f, 0f, Math.min(bw, bh), Math.max(bw, bh));
    }

    viewToImageMatrix.setRectToRect(bitmapRect, viewRect, viewPolicy);

    if (vw > vh ^ bw > bh) {
        // Turn centerImageMatrix by 90 degrees
        Matrix m = new Matrix();
        m.postRotate(90f);
        m.postTranslate(bh, 0);

        viewToImageMatrix.preConcat(m);
    }

    if (!viewToImageMatrix.invert(inverseViewToImageMatrix)) {
        throw new IllegalArgumentException("matrix cannot be inverted...");
    }

    imageView.setImageMatrix(viewToImageMatrix);
}

From source file:fr.francetv.zoom.share.loader.ZoomLoaderView.java

private void init() {
    mIsRunning = false;/*from   w w w  . j  a v a  2s.c  o  m*/

    mViewWidthPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, VIEW_WIDTH_DP,
            getResources().getDisplayMetrics());
    mViewHeightPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, VIEW_HEIGHT_DP,
            getResources().getDisplayMetrics());

    mRadiusPx = mViewHeightPx / 2;

    mMaskBitmap = Bitmap.createBitmap(mViewWidthPx, mViewHeightPx, Bitmap.Config.ARGB_8888);
    new Canvas(mMaskBitmap).drawBitmap(
            BitmapFactory.decodeResource(getContext().getResources(), R.drawable.img_loader_mask), 0, 0, null);

    mMaskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mMaskPaint.setFilterBitmap(false);
    mMaskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));

    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setFilterBitmap(false);
    mBackgroundPaint.setXfermode(null);
    mBackgroundPaint.setColor(ContextCompat.getColor(getContext(), android.R.color.darker_gray));

    // Circles
    mAnimPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mAnimPaint.setXfermode(null);
    mAnimPaint.setColor(ContextCompat.getColor(getContext(), android.R.color.holo_green_light));

    mLeftCircleArc = new RectF(0, 0, 2 * mRadiusPx, 2 * mRadiusPx);
    mRightCircleArc = new RectF(mViewWidthPx - 2 * mRadiusPx, 0, mViewWidthPx, 2 * mRadiusPx);

    //Anims
    mAnimationIn = ValueAnimator.ofInt(0, 361 + LEFT_START_DEGRE);
    mAnimationIn.setInterpolator(new FastOutSlowInInterpolator());
    mAnimationIn.addUpdateListener(mAnimationInUpdateListener);
    mAnimationIn.addListener(mAnimationInListener);
    mAnimationIn.setDuration(ANIMATION_IN_DURATION_MS);

    mAnimationOut = ValueAnimator.ofInt(0, 361 + LEFT_START_DEGRE);
    mAnimationOut.setInterpolator(new FastOutSlowInInterpolator());
    mAnimationOut.addUpdateListener(mAnimationOutUpdateListener);
    mAnimationOut.addListener(mAnimationOutListener);
    mAnimationOut.setDuration(ANIMATION_OUT_DURATION_MS);

    mDelayHandler = new DelayHandler(mAnimationOut);
}

From source file:com.tbse.mywearapplication.WatchFaceDrawer.java

void onDraw(Context context, IWatchFaceConfig config, Canvas canvas, Rect bounds) {
    final Calendar calendar = config.getCalendar();
    final boolean isAmbient = config.isAmbient();
    final boolean isRound = config.isRound();
    final boolean useLightTheme = !isAmbient && config.isLightTheme();

    mBackgroundPaint.setColor(ContextCompat.getColor(context,
            useLightTheme ? R.color.watchface_background_light : R.color.watchface_background));

    /////////////////////////////////////////////////////////////////////
    // Draw your watch face here, using the provided canvas and bounds //
    /////////////////////////////////////////////////////////////////////

    final int width = bounds.width();
    final int height = bounds.height();

    // Find the center. Ignore the window insets so that, on round
    // watches with a "chin", the watch face is centered on the entire
    // screen, not just the usable portion.
    final float centerX = width / 2f;
    final float centerY = height / 2f;

    // Draw the background.
    if (mIsMobilePreview) {
        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mPreviewBorderPaint);
        } else {//from   ww  w.jav a 2 s  .c o m
            final float radius = mPreviewSquareRadius;
            final RectF rectF = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
            canvas.drawRoundRect(rectF, radius, radius, mPreviewBorderPaint);
        }

        final float translateXY = width * 0.05f;
        canvas.translate(translateXY, translateXY);
        canvas.scale(0.9f, 0.9f);

        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mBackgroundPaint);
        } else {
            canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
        }
    } else {
        canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
    }

    // Draw weather icon
    if (image != null) {
        Matrix matrix = new Matrix();
        matrix.setTranslate(50, 90);
        matrix.preScale(0.2f, 0.2f);
        canvas.drawBitmap(image, matrix, null);
    }

    final float secRot = calendar.get(Calendar.SECOND) / 30f * (float) Math.PI;
    final int minutes = calendar.get(Calendar.MINUTE);
    final float minRot = minutes / 30f * (float) Math.PI;
    final float hrRot = ((calendar.get(Calendar.HOUR) + (minutes / 60f)) / 6f) * (float) Math.PI;

    final float secLength = centerX - mSecondOuterOffset;
    final float minLength = centerX - mMinuteOuterOffset;
    final float hrLength = centerX - mHourOuterOffset;

    if (!isAmbient) {
        final float secX = (float) Math.sin(secRot) * secLength;
        final float secY = (float) -Math.cos(secRot) * secLength;
        canvas.drawLine(centerX, centerY, centerX + secX, centerY + secY, mSecondHandPaint);
    }

    final float minX = (float) Math.sin(minRot) * minLength;
    final float minY = (float) -Math.cos(minRot) * minLength;
    canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mMinuteHandPaint);

    final float hrX = (float) Math.sin(hrRot) * hrLength;
    final float hrY = (float) -Math.cos(hrRot) * hrLength;
    canvas.drawLine(centerX, centerY, centerX + hrX, centerY + hrY, mHourHandPaint);

    // Draw weather text
    canvas.drawText(day, 50, 50, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(low, 50, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(high, 80, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(weatherDescription, 50, 80, isAmbient ? ambientTextPaint : textPaint);

}

From source file:com.liferay.mobile.screens.viewsets.defaultviews.userportrait.UserPortraitView.java

protected RectF getRectF(Bitmap bitmap, float borderWidth) {
    RectF rect = new RectF(0.0f, 0.0f, bitmap.getWidth(), bitmap.getHeight());
    rect.inset(borderWidth, borderWidth);
    return rect;/*from w w  w .java  2  s  . co m*/
}

From source file:com.e.common.widget.viewpager.UnderlinePageIndicator.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (mViewPager == null) {
        return;//from   www  .j  av  a  2 s  .c o m
    }
    final int count = mViewPager.getAdapter().getCount();
    if (count == 0) {
        return;
    }

    if (mCurrentPage >= count) {
        setCurrentItem(count - 1);
        return;
    }

    final int paddingLeft = getPaddingLeft();
    final float pageWidth = (getWidth() - paddingLeft - getPaddingRight()) / (1f * count);
    final float left = paddingLeft + pageWidth * (mCurrentPage + mPositionOffset);
    final float right = left + pageWidth;
    final float top = getPaddingTop();
    final float bottom = getHeight() - getPaddingBottom();
    if (isRound) {
        int radius = getHeight() / 2;
        canvas.drawRoundRect(new RectF(left, top, right, bottom), radius, radius, mPaint);
    } else {
        canvas.drawRect(left, top, right, bottom, mPaint);
    }
}

From source file:org.ietf.ietfsched.ui.SessionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_detail, container, false);
    mTabHost = (TabHost) mRootView.findViewById(android.R.id.tabhost);
    mTabHost.setup();/*from w ww . ja  v a2 s  . co  m*/

    mTitle = (TextView) mRootView.findViewById(R.id.session_title);
    mSubtitle = (TextView) mRootView.findViewById(R.id.session_subtitle);
    mStarred = (CompoundButton) mRootView.findViewById(R.id.star_button);

    mStarred.setFocusable(true);
    mStarred.setClickable(true);

    // Larger target triggers star toggle
    final View starParent = mRootView.findViewById(R.id.header_session);
    FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f));

    mAbstract = (TextView) mRootView.findViewById(R.id.session_abstract);
    //        mRequirements = (TextView) mRootView.findViewById(R.id.session_requirements);

    setupLinksTab();
    setupNotesTab();
    setupSummaryTab();

    return mRootView;
}