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() 

Source Link

Document

Create a new empty RectF.

Usage

From source file:com.fjoglar.etsitnoticias.view.widget.InkPageIndicator.java

public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;/*www . ja v a 2 s .c om*/
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        interpolator = AnimUtils.getFastOutSlowInInterpolator(context);
    } else {
        interpolator = null;
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:org.goodev.material.widget.InkPageIndicator.java

public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;/*from ww w  .  j  av a 2s  . c om*/
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    if (UI.isLollipop()) {
        interpolator = android.view.animation.AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
    } else {
        interpolator = android.view.animation.AnimationUtils.loadInterpolator(context,
                android.R.interpolator.accelerate_decelerate);
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}

From source file:org.smart.library.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;//from w  w w.  j  a  v  a 2s . c  o  m
    if (shape == 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;

    int mCircleSize = Math.round(height * 0.8f);
    space = (height - mCircleSize) / 4;
    if (!measureSlide && mCircleSize > 0) {
        /** ? */
        if (circle_off_bitmap != null) {
            // int circleHeight = circle_off_bitmap.getHeight();
            // float mScale = circleHeight > mCircleSize ? circleHeight *
            // 1.0f / mCircleSize : 1;
            // circleHeight = Math.round(circleHeight * mScale);
            // int mOffWidth = Math.round(circle_off_bitmap.getWidth() *
            // mScale);
            // if (mOffWidth > 0) {
            // circle_off_bitmap = ImageUtils.zoomImage(circle_off_bitmap,
            // mOffWidth, height);
            // measureSlide = !measureSlide;
            // }
            circle_off_bitmap = ImageUtils.zoomImage(circle_off_bitmap, mCircleSize, mCircleSize);
            measureSlide = !measureSlide;
        }
        if (circle_on_bitmap != null) {
            // float mScale = circle_on_bitmap.getHeight() / mCircleSize;
            // int mOnWidth = Math.round(circle_on_bitmap.getWidth() *
            // mScale);
            // if (mOnWidth > 0) {
            // circle_on_bitmap = ImageUtils.zoomImage(circle_on_bitmap,
            // mOnWidth, height);
            // measureSlide = !measureSlide;
            // }
            circle_on_bitmap = ImageUtils.zoomImage(circle_on_bitmap, mCircleSize, mCircleSize);
            measureSlide = !measureSlide;
        }
    }
}

From source file:com.android.settings.widget.DotsPageIndicator.java

public DotsPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final int scaledDensity = (int) context.getResources().getDisplayMetrics().scaledDensity;

    // Load attributes
    final TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.DotsPageIndicator,
            defStyle, 0);// ww w. j  a v a  2  s. c  om
    dotDiameter = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * scaledDensity);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotGap, DEFAULT_GAP * scaledDensity);
    animDuration = (long) typedArray.getInteger(R.styleable.DotsPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);
    typedArray.recycle();
    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = loadInterpolator(context, android.R.interpolator.fast_out_slow_in);
    } else {
        interpolator = loadInterpolator(context, android.R.anim.accelerate_decelerate_interpolator);
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
            attachedState = true;
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            attachedState = false;
        }
    });
}

From source file:nuclei.ui.view.GlideImageView.java

public void setBorder(@ColorInt int color, float width) {
    if (mBorderPaint == null) {
        mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mBorderPaint.setStyle(Paint.Style.STROKE);
    }/*  ww  w . j  av  a 2 s .  c  o m*/
    if (mBorderRect == null)
        mBorderRect = new RectF();
    mBorderPaint.setColor(color);
    mBorderPaint.setStrokeWidth(width);
    invalidate();
}

From source file:com.frapim.windwatch.Notifier.java

private Path getArrowPath(float degrees) {
    Path path = new Path();
    int leftX = (mBigIconSize / 2) - (mArrowWidth / 2);
    int leftHeadX = leftX - mArrowWidth;
    int rightX = (mBigIconSize / 2) + (mArrowWidth / 2);
    int rightHeadX = rightX + mArrowWidth;
    path.moveTo(leftX, mArrowHeight); // bottom left
    path.lineTo(leftX, mArrowHeadHeight); // left, arrow head start
    path.lineTo(leftHeadX, mArrowHeadHeight); //  left, arrow head end 
    path.lineTo(mBigIconSize / 2, 0); // top
    path.lineTo(rightHeadX, mArrowHeadHeight); // right, arrow head end
    path.lineTo(rightX, mArrowHeadHeight); // right, arrow head start
    path.lineTo(rightX, mArrowHeight); // bottom right
    path.lineTo(leftX, mArrowHeight); // bottom left
    path.close();//from w w  w  .j  av  a2s  . co m
    Matrix translateMatrix = new Matrix();
    translateMatrix.postTranslate(0, 30);
    path.transform(translateMatrix);
    RectF bounds = new RectF();
    path.computeBounds(bounds, true);
    Matrix rotateMatrix = new Matrix();
    rotateMatrix.postRotate(degrees, (bounds.right + bounds.left) / 2, (bounds.bottom + bounds.top) / 2);
    path.transform(rotateMatrix);
    return path;
}

From source file:com.abslyon.abetterselection.CoverFlow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);// w  ww  .  j a  v a 2 s.  c o m
    setClickable(true);

    mChildTransfromer = new Matrix();
    mReflectionTransfromer = new Matrix();

    mTouchRect = new RectF();

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());

    mRemoveReflectionPendingArray = new ArrayList<Integer>();
}

From source file:com.dolphinwang.imagecoverflow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);/* www.j  a va 2 s  .c  o m*/
    setClickable(true);

    mChildTransfromer = new Matrix();
    mReflectionTransfromer = new Matrix();

    mTouchRect = new RectF();

    mTouchRect2 = new ArrayList<RectF>();
    for (int i = 0; i < 5; i++) {
        RectF a = new RectF();
        mTouchRect2.add(a);
    }

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());

    mRemoveReflectionPendingArray = new ArrayList<Integer>();
}

From source file:com.lovejjfg.demo.TouchCircleView.java

private void initView() {
    setupAnimations();/*from   w  ww .  j a  va  2 s .  com*/
    innerRectf = new RectF();
    secondRectf = new RectF();
    outRectF = new RectF();
    ARROW_WIDTH = (int) (mBorderWidth * 1.5f);
    ARROW_HEIGHT = (int) (mBorderWidth * 0.75f);
    initPaintPath();
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);//w  ww . j  av  a2 s . c om
    setClickable(true);

    mChildTransformer = new Matrix();
    mReflectionTransformer = new Matrix();

    mTouchRect = new RectF();

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());
}