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:org.jraf.android.cinetoday.mobile.ui.CirclePageIndicator.java

@Override
protected void onDraw(Canvas canvas) {
    if (mViewPager == null)
        return;//ww  w.j a  v a  2 s . c om
    int count = mViewPager.getAdapter().getCount();
    if (count == 0)
        return;

    for (int i = 0; i < count; i++) {
        float x = i * (mCircleRadiusPx * 2 + mCircleMarginPx) + mCircleRadiusPx + mCircleMarginPx / 2;
        float y = mCircleRadiusPx;
        float radius;
        if (i == mPosition) {
            radius = mCircleRadiusPx - mCircleRadiusPx * SHRINK_FACTOR * mPositionOffset;
        } else if (i == mPosition + 1) {
            radius = mCircleRadiusPx - mCircleRadiusPx * SHRINK_FACTOR * (1f - mPositionOffset);
        } else {
            radius = mCircleRadiusPx - mCircleRadiusPx * SHRINK_FACTOR;
        }

        if (i == count - 1) {
            // Draw a '+'
            RectF dst = new RectF();
            dst.left = x - radius;
            dst.right = x + radius;
            dst.top = y - radius;
            dst.bottom = y + radius;
            canvas.drawBitmap(mAddBitmap, null, dst, mPaint);
        } else {
            // Draw a circle
            canvas.drawCircle(x, y, radius, mPaint);
        }
    }
}

From source file:com.cleveroad.audiowidget.AudioWidget.java

@SuppressWarnings("deprecation")
private AudioWidget(@NonNull Builder builder) {
    this.context = builder.context.getApplicationContext();
    this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    this.handler = new Handler();
    this.screenSize = new Point();
    this.removeBounds = new RectF();
    this.hiddenRemWidPos = new Point();
    this.visibleRemWidPos = new Point();
    this.controller = newController();
    this.windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getSize(screenSize);
    screenSize.y -= statusBarHeight() + navigationBarHeight();

    Configuration configuration = prepareConfiguration(builder);
    playPauseButton = new PlayPauseButton(configuration);
    expandCollapseWidget = new ExpandCollapseWidget(configuration);
    removeWidgetView = new RemoveWidgetView(configuration);
    int offsetCollapsed = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_collapsed);
    int offsetExpanded = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_expanded);
    playPauseButtonManager = new TouchManager(playPauseButton,
            playPauseButton.newBoundsChecker(
                    builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed,
                    builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed))
                            .screenWidth(screenSize.x).screenHeight(screenSize.y);
    expandedWidgetManager = new TouchManager(expandCollapseWidget,
            expandCollapseWidget.newBoundsChecker(
                    builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded,
                    builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded))
                            .screenWidth(screenSize.x).screenHeight(screenSize.y);

    playPauseButtonManager.callback(new PlayPauseButtonCallback());
    expandedWidgetManager.callback(new ExpandCollapseWidgetCallback());
    expandCollapseWidget.onWidgetStateChangedListener(new OnWidgetStateChangedListener() {
        @Override//  w w w . ja v  a 2 s  .co  m
        public void onWidgetStateChanged(@NonNull State state) {
            if (state == State.COLLAPSED) {
                playPauseButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                try {
                    windowManager.removeView(expandCollapseWidget);
                } catch (IllegalArgumentException e) {
                    // view not attached to window
                }
                playPauseButton.enableProgressChanges(true);
            }
            if (onWidgetStateChangedListener != null) {
                onWidgetStateChangedListener.onWidgetStateChanged(state);
            }
        }

        @Override
        public void onWidgetPositionChanged(int cx, int cy) {

        }
    });
    onControlsClickListener = new OnControlsClickListenerWrapper();
    expandCollapseWidget.onControlsClickListener(onControlsClickListener);
    ppbToExpBoundsChecker = playPauseButton.newBoundsChecker(
            builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded,
            builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded);
    expToPpbBoundsChecker = expandCollapseWidget.newBoundsChecker(
            builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed,
            builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed);
}

From source file:com.chrisrenke.giv.GravityImageView.java

public GravityImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    matrix = new Matrix();
    imageRect = new RectF();

    // By nature of this view, only MATRIX is supported. If ya want to use other
    // scaleTypes, use an ImageView.
    setScaleType(MATRIX);// ww w  .j a va 2  s.  com

    // Support for END/START.
    isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;

    // Early exit for whiziwiggin' it.
    if (isInEditMode())
        return;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GravityImageView, //
            defStyleAttr, 0);
    imageScaleMode = a.getInt(R.styleable.GravityImageView_imageScaleMode, NONE);
    imageGravity = a.getInt(R.styleable.GravityImageView_imageGravity, CENTER);
    a.recycle();
}

From source file:com.dean.phonesafe.ui.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 ww w  .ja  va  2  s . com
    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;
}

From source file:com.tr4android.support.extension.widget.CollapsingTextHelper.java

public CollapsingTextHelper(View view) {
    mView = view;//from w ww  . j a  v a 2 s  .  co  m

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);

    mCollapsedBounds = new Rect();
    mExpandedBounds = new Rect();
    mCurrentBounds = new RectF();
}

From source file:lollipop.iconics.IconicsDrawable.java

private void prepare() {
    mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mContourPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mContourPaint.setStyle(Paint.Style.STROKE);

    mPath = new Path();

    mPathBounds = new RectF();
    mPaddingBounds = new Rect();
}

From source file:android.support.design.widget.SubtitleCollapsingTextHelper.java

public SubtitleCollapsingTextHelper(View view) {
    mView = view;/*  ww  w .j a  va  2 s.c o m*/
    mTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    mCollapsedBounds = new Rect();
    mExpandedBounds = new Rect();
    mCurrentBounds = new RectF();
}

From source file:com.muzakki.ahmad.widget.CollapsingTextHelper.java

public CollapsingTextHelper(View view) {
    mView = view;//from   w  w w .j  av a 2 s  .  c o  m

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); // modification

    mCollapsedBounds = new Rect();
    mExpandedBounds = new Rect();
    mCurrentBounds = new RectF();
}

From source file:android.support.design.widget.CustomCollapsingTextHelper.java

public CustomCollapsingTextHelper(View view) {
    mView = view;//from  www . j  a  v a  2  s .  c  om
    mTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    mCollapsedBounds = new Rect();
    mExpandedBounds = new Rect();
    mCurrentBounds = new RectF();
}

From source file:org.connectbot.TerminalView.java

public TerminalView(Context context, TerminalBridge bridge) {
    super(context);

    this.context = context;
    this.bridge = bridge;
    paint = new Paint();

    setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    setFocusable(true);/*from   ww w  .j a v  a  2  s. c  o  m*/
    setFocusableInTouchMode(true);

    cursorPaint = new Paint();
    cursorPaint.setColor(bridge.color[bridge.defaultFg]);
    cursorPaint.setXfermode(new PixelXorXfermode(bridge.color[bridge.defaultBg]));
    cursorPaint.setAntiAlias(true);

    cursorStrokePaint = new Paint(cursorPaint);
    cursorStrokePaint.setStrokeWidth(0.1f);
    cursorStrokePaint.setStyle(Paint.Style.STROKE);

    /*
     * Set up our cursor indicators on a 1x1 Path object which we can later
     * transform to our character width and height
     */
    // TODO make this into a resource somehow
    shiftCursor = new Path();
    shiftCursor.lineTo(0.5f, 0.33f);
    shiftCursor.lineTo(1.0f, 0.0f);

    altCursor = new Path();
    altCursor.moveTo(0.0f, 1.0f);
    altCursor.lineTo(0.5f, 0.66f);
    altCursor.lineTo(1.0f, 1.0f);

    ctrlCursor = new Path();
    ctrlCursor.moveTo(0.0f, 0.25f);
    ctrlCursor.lineTo(1.0f, 0.5f);
    ctrlCursor.lineTo(0.0f, 0.75f);

    // For creating the transform when the terminal resizes
    tempSrc = new RectF();
    tempSrc.set(0.0f, 0.0f, 1.0f, 1.0f);
    tempDst = new RectF();
    scaleMatrix = new Matrix();

    bridge.addFontSizeChangedListener(this);

    // connect our view up to the bridge
    setOnKeyListener(bridge.getKeyHandler());

    mAccessibilityBuffer = new StringBuffer();

    // Enable accessibility features if a screen reader is active.
    new AccessibilityStateTester().execute((Void) null);
}