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.chrynan.guitarchords.view.GuitarChordView.java

@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
    //TODO adjust lowest and highest notes to be within the draw bounds (notes on 1st and 6th string exceed draw bounds by half
    //the note size)
    float aWidth = (float) width - ((float) (getPaddingLeft() + getPaddingRight()));
    float aHeight = (float) width - ((float) (getPaddingTop() + getPaddingBottom()));
    float pWidth = aWidth;
    float pHeight = aHeight;
    float w = aHeight * (2f / 3f);
    if (w <= aWidth) {
        aWidth = w;/*  ww  w  . j av  a2 s  .c o  m*/
    } else {
        aHeight = 3 * (aWidth / 2);
    }
    //Center everything
    drawingBounds = new RectF((pWidth - aWidth) / 2, (pHeight - aHeight) / 2, (pWidth - aWidth) / 2 + aWidth,
            (pHeight - aHeight) / 2 + aHeight);
    if (showFretNumbers) {
        fretNumberSize = (int) ((aWidth / (stringCount + 1)) * (3f / 4f));
        stringMarkerSize = fretNumberSize;
        stringDistance = (aWidth - (fretNumberSize + (fretNumberSize / 2))) / stringCount;
    } else {
        fretNumberSize = 0;
        stringMarkerSize = (int) ((aWidth / (stringCount + 1)) * (3f / 4f));
        stringDistance = aWidth / stringCount;
    }
    stringSize = stringDistance / stringCount;
    stringSize = (stringSize < 1) ? 1 : stringSize;
    fretMarkerSize = (int) stringSize;
    bridgeNutSize = (int) (3 * stringSize);
    noteSize = (int) stringDistance;
    noteNumberSize = (int) (noteSize * (3f / 4f));
    //TODO need to take into account whether or not to show bridgeNut
    int fretCount = (chord != null && chord.getFretCount() >= 4) ? chord.getFretCount() : 4;
    fretSize = Math
            .round(((aHeight - (fretNumberSize + fretNumberSize / 2)) - ((fretCount + 1) * fretMarkerSize))
                    / fretCount);
    if (showFretNumbers) {
        stringMarkerBounds = new RectF(drawingBounds.left + (fretNumberSize + (fretNumberSize / 2)),
                drawingBounds.top, drawingBounds.right,
                drawingBounds.top + (stringMarkerSize + (stringMarkerSize / 2)));
        fretNumberBounds = new RectF(drawingBounds.left, stringMarkerBounds.bottom,
                drawingBounds.left + (fretNumberSize + (fretNumberSize / 2)), drawingBounds.bottom);
    } else {
        stringMarkerBounds = new RectF(drawingBounds.left, drawingBounds.top, drawingBounds.right,
                drawingBounds.top + (stringMarkerSize + (stringMarkerSize / 2)));
        fretNumberBounds = new RectF(0, 0, 0, 0);
    }
    setPaintSizes();
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java

private void setupSearchMenu(MenuItem searchMenu) {
    search = searchMenu;//from   w  ww.j  a v a2  s  .  c o  m
    MenuItemCompat.setOnActionExpandListener(searchMenu, new MenuItemCompat.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            final EditText field = (EditText) MenuItemCompat.getActionView(item)
                    .findViewById(R.id.search_field);
            field.requestFocus();
            InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            keyboard.toggleSoftInput(0, 0);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            EditText field = (EditText) MenuItemCompat.getActionView(item).findViewById(R.id.search_field);
            InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            keyboard.hideSoftInputFromWindow(field.getWindowToken(), 0);
            return true;
        }
    });
    MenuItemCompat.getActionView(searchMenu).findViewById(R.id.search_field)
            .setOnKeyListener(new View.OnKeyListener() {
                @SuppressWarnings("unchecked")
                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    if (keyCode == KeyEvent.KEYCODE_ENTER) {
                        EditText field = ((EditText) MenuItemCompat.getActionView(search)
                                .findViewById(R.id.search_field));
                        MenuItemCompat.collapseActionView(search);
                        Projection projection = mapView.getProjection();
                        GeoPoint topLeft = projection.fromPixels(0, 0);
                        GeoPoint bottomRight = projection.fromPixels(mapView.getWidth(), mapView.getHeight());
                        GeoCodingHandler.createDefaultHandler(geoCodingListener, field.getText().toString(),
                                new RectF((float) topLeft.getLongitude(), (float) topLeft.getLatitude(),
                                        (float) bottomRight.getLongitude(), (float) bottomRight.getLatitude()))
                                .execute();
                    }
                    return false;
                }
            });
}

From source file:com.example.linhdq.test.documents.creation.crop.CropImageActivity.java

private void showDefaultCroppingRectangle(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    Rect imageRect = new Rect(0, 0, width, height);

    // make the default size about 4/5 of the width or height
    int cropWidth = Math.min(width, height) * 4 / 5;

    int x = (width - cropWidth) / 2;
    int y = (height - cropWidth) / 2;

    RectF cropRect = new RectF(x, y, x + cropWidth, y + cropWidth);

    CropHighlightView hv = new CropHighlightView(mImageView, imageRect, cropRect);

    mImageView.resetMaxZoom();//w  w  w .  j  a v  a  2s.  c om
    mImageView.add(hv);
    mCrop = hv;
    mCrop.setFocus(true);
    mImageView.invalidate();
}

From source file:com.andexert.calendarlistview.library.SimpleMonthView.java

protected void drawMonthNums(Canvas canvas) {
    int y = (mRowHeight + MINI_DAY_NUMBER_TEXT_SIZE) / 2 - DAY_SEPARATOR_WIDTH + MONTH_HEADER_SIZE;
    int paddingDay = (mWidth - 2 * mPadding) / (2 * mNumDays);
    int dayOffset = findDayOffset();
    int day = 1;/*from  w w  w . j av a2s  .  c om*/
    String toDayRes = getResources().getString(R.string.today);
    while (day <= mNumCells) {
        boolean isShowTrain = true;
        int x = paddingDay * (1 + dayOffset * 2) + mPadding;
        if ((mMonth == mSelectedBeginMonth && mSelectedBeginDay == day && mSelectedBeginYear == mYear)
                || (mMonth == mSelectedLastMonth && mSelectedLastDay == day && mSelectedLastYear == mYear)) {
            if (mDrawRect) {
                RectF rectF = new RectF(x - DAY_SELECTED_CIRCLE_SIZE,
                        (y - MINI_DAY_NUMBER_TEXT_SIZE / 3) - DAY_SELECTED_CIRCLE_SIZE,
                        x + DAY_SELECTED_CIRCLE_SIZE,
                        (y - MINI_DAY_NUMBER_TEXT_SIZE / 3) + DAY_SELECTED_CIRCLE_SIZE);
                canvas.drawRoundRect(rectF, 10.0f, 10.0f, mSelectedCirclePaint);
            } else {
                canvas.drawCircle(x, y - MINI_DAY_NUMBER_TEXT_SIZE / 3, DAY_SELECTED_CIRCLE_SIZE,
                        mSelectedCirclePaint);
            }
            isShowTrain = false;
        }
        if (mHasToday && (mToday == day)) {
            mMonthNumPaint.setColor(mCurrentDayTextColor);
        } else {
            mMonthNumPaint.setColor(mDayNumColor);
            mMonthNumPaint.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        }

        if ((mMonth == mSelectedBeginMonth && mSelectedBeginDay == day && mSelectedBeginYear == mYear)
                || (mMonth == mSelectedLastMonth && mSelectedLastDay == day && mSelectedLastYear == mYear))
            mMonthNumPaint.setColor(mMonthTitleBGColor);

        if ((mSelectedBeginDay != -1 && mSelectedLastDay != -1 && mSelectedBeginYear == mSelectedLastYear
                && mSelectedBeginMonth == mSelectedLastMonth && mSelectedBeginDay == mSelectedLastDay
                && day == mSelectedBeginDay && mMonth == mSelectedBeginMonth && mYear == mSelectedBeginYear)) {
            mMonthNumPaint.setColor(mSelectedDaysColor);
        }
        //?
        if ((mSelectedBeginDay != -1 && mSelectedLastDay != -1 && mSelectedBeginYear == mSelectedLastYear
                && mSelectedBeginYear == mYear)
                && (((mMonth == mSelectedBeginMonth && mSelectedLastMonth == mSelectedBeginMonth)
                        && ((mSelectedBeginDay < mSelectedLastDay && day > mSelectedBeginDay
                                && day < mSelectedLastDay)
                                || (mSelectedBeginDay > mSelectedLastDay && day < mSelectedBeginDay
                                        && day > mSelectedLastDay)))
                        || ((mSelectedBeginMonth < mSelectedLastMonth && mMonth == mSelectedBeginMonth
                                && day > mSelectedBeginDay)
                                || (mSelectedBeginMonth < mSelectedLastMonth && mMonth == mSelectedLastMonth
                                        && day < mSelectedLastDay))
                        || ((mSelectedBeginMonth > mSelectedLastMonth && mMonth == mSelectedBeginMonth
                                && day < mSelectedBeginDay)
                                || (mSelectedBeginMonth > mSelectedLastMonth && mMonth == mSelectedLastMonth
                                        && day > mSelectedLastDay)))) {
            mMonthNumPaint.setColor(mSelectedDaysColor);
        }

        if ((mSelectedBeginDay != -1 && mSelectedLastDay != -1 && mSelectedBeginYear != mSelectedLastYear
                && ((mSelectedBeginYear == mYear && mMonth == mSelectedBeginMonth)
                        || (mSelectedLastYear == mYear && mMonth == mSelectedLastMonth))
                && (((mSelectedBeginMonth < mSelectedLastMonth && mMonth == mSelectedBeginMonth
                        && day < mSelectedBeginDay)
                        || (mSelectedBeginMonth < mSelectedLastMonth && mMonth == mSelectedLastMonth
                                && day > mSelectedLastDay))
                        || ((mSelectedBeginMonth > mSelectedLastMonth && mMonth == mSelectedBeginMonth
                                && day > mSelectedBeginDay)
                                || (mSelectedBeginMonth > mSelectedLastMonth && mMonth == mSelectedLastMonth
                                        && day < mSelectedLastDay))))) {
            mMonthNumPaint.setColor(mSelectedDaysColor);
        }

        if ((mSelectedBeginDay != -1 && mSelectedLastDay != -1 && mSelectedBeginYear == mSelectedLastYear
                && mYear == mSelectedBeginYear)
                && ((mMonth > mSelectedBeginMonth && mMonth < mSelectedLastMonth
                        && mSelectedBeginMonth < mSelectedLastMonth)
                        || (mMonth < mSelectedBeginMonth && mMonth > mSelectedLastMonth
                                && mSelectedBeginMonth > mSelectedLastMonth))) {
            mMonthNumPaint.setColor(mSelectedDaysColor);
        }

        if ((mSelectedBeginDay != -1 && mSelectedLastDay != -1 && mSelectedBeginYear != mSelectedLastYear)
                && ((mSelectedBeginYear < mSelectedLastYear
                        && ((mMonth > mSelectedBeginMonth && mYear == mSelectedBeginYear)
                                || (mMonth < mSelectedLastMonth && mYear == mSelectedLastYear)))
                        || (mSelectedBeginYear > mSelectedLastYear
                                && ((mMonth < mSelectedBeginMonth && mYear == mSelectedBeginYear)
                                        || (mMonth > mSelectedLastMonth && mYear == mSelectedLastYear))))) {
            mMonthNumPaint.setColor(mSelectedDaysColor);
        }

        if ((!isPrevDayEnabled && prevDay(day, today)) || nextDay(day)) {
            mMonthNumPaint.setColor(mPreviousDayColor);
        }
        if (mHasToday && (mToday == day)) {
            canvas.drawText(toDayRes, x, y, mMonthNumPaint);
        } else {
            canvas.drawText(String.format("%d", day), x, y, mMonthNumPaint);
        }
        dayOffset++;
        if (dayOffset == mNumDays) {
            dayOffset = 0;
            y += mRowHeight;
        }
        day++;
    }
}

From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java

private void init(Context context, AttributeSet attrs) {
    float barHeight;
    int thumbNormal = R.drawable.seek_thumb;
    int thumbPressed = R.drawable.seek_thumb_pressed;
    int thumbDisabled = R.drawable.seek_thumb_disabled;
    int thumbShadowColor;
    int defaultShadowColor = Color.argb(75, 0, 0, 0);
    int defaultShadowYOffset = PixelUtil.dpToPx(context, 2);
    int defaultShadowXOffset = PixelUtil.dpToPx(context, 0);
    int defaultShadowBlur = PixelUtil.dpToPx(context, 2);

    offset = PixelUtil.dpToPx(context, TEXT_LATERAL_PADDING_IN_DP);
    textSeperation = PixelUtil.dpToPx(context, DEFAULT_TEXT_SEPERATION_IN_DP);
    step = DEFAULT_STEP;// www . j  a va 2s  .c o m
    snapTolerance = DEFAULT_SNAP_TOLERANCE_PERCENT / 100;
    minimumDistance = DEFAULT_MINIMUM_DISTANCE;
    increments = DEFAULT_INCREMENTS;
    incrementRanges = DEFAULT_INCREMENT_RANGES;

    if (attrs == null) {
        rangeType = DEFAULT_RANGE_TYPE;
        setRangeToDefaultValues();
        mInternalPad = PixelUtil.dpToPx(context, INITIAL_PADDING_IN_DP);
        barHeight = PixelUtil.dpToPx(context, LINE_HEIGHT_IN_DP);
        mActiveColor = ACTIVE_COLOR;
        mDefaultColor = Color.parseColor("#e5e8eb");
        mAlwaysActive = true;
        mShowTextAboveThumbs = true;
        mTextAboveThumbsColor = Color.WHITE;
        thumbShadowColor = defaultShadowColor;
        mThumbShadowXOffset = defaultShadowXOffset;
        mThumbShadowYOffset = defaultShadowYOffset;
        mThumbShadowBlur = defaultShadowBlur;
        mActivateOnDefaultValues = true;
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RangeSeekBar, 0, 0);
        try {
            switch (a.getInt(R.styleable.RangeSeekBar_rangeType, 0)) {
            case 0:
                rangeType = RangeType.LINEAR;
                break;
            case 1:
                rangeType = RangeType.PREDEFINED;
                break;
            case 2:
                rangeType = RangeType.CUBIC;
                break;
            default:
                rangeType = RangeType.LINEAR;
            }
            setRangeValues(
                    extractNumericValueFromAttributes(a, R.styleable.RangeSeekBar_absoluteMinValue,
                            DEFAULT_MINIMUM),
                    extractNumericValueFromAttributes(a, R.styleable.RangeSeekBar_absoluteMaxValue,
                            DEFAULT_MAXIMUM));
            mShowTextAboveThumbs = a.getBoolean(R.styleable.RangeSeekBar_valuesAboveThumbs, true);
            mTextAboveThumbsColor = a.getColor(R.styleable.RangeSeekBar_textAboveThumbsColor, Color.WHITE);
            mSingleThumb = a.getBoolean(R.styleable.RangeSeekBar_singleThumb, false);
            mShowLabels = a.getBoolean(R.styleable.RangeSeekBar_showLabels, true);
            mInternalPad = PixelUtil.dpToPx(context,
                    a.getInt(R.styleable.RangeSeekBar_internalPadding, INITIAL_PADDING_IN_DP));
            barHeight = PixelUtil.dpToPx(context,
                    a.getInt(R.styleable.RangeSeekBar_barHeight, LINE_HEIGHT_IN_DP));
            mActiveColor = a.getColor(R.styleable.RangeSeekBar_activeColor, ACTIVE_COLOR);
            mDefaultColor = a.getColor(R.styleable.RangeSeekBar_defaultColor, Color.parseColor("#e5e8eb"));
            mAlwaysActive = a.getBoolean(R.styleable.RangeSeekBar_alwaysActive, true);
            customMinValueLabel = a.getString(R.styleable.RangeSeekBar_minValueLabel);
            customMaxValueLabel = a.getString(R.styleable.RangeSeekBar_maxValueLabel);

            Drawable normalDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbNormal);
            if (normalDrawable != null) {
                thumbImage = BitmapUtil.drawableToBitmap(normalDrawable);
            }
            Drawable disabledDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbDisabled);
            if (disabledDrawable != null) {
                thumbDisabledImage = BitmapUtil.drawableToBitmap(disabledDrawable);
            }
            Drawable pressedDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbPressed);
            if (pressedDrawable != null) {
                thumbPressedImage = BitmapUtil.drawableToBitmap(pressedDrawable);
            }
            mThumbShadow = a.getBoolean(R.styleable.RangeSeekBar_thumbShadow, false);
            thumbShadowColor = a.getColor(R.styleable.RangeSeekBar_thumbShadowColor, defaultShadowColor);
            mThumbShadowXOffset = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowXOffset,
                    defaultShadowXOffset);
            mThumbShadowYOffset = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowYOffset,
                    defaultShadowYOffset);
            mThumbShadowBlur = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowBlur,
                    defaultShadowBlur);

            mActivateOnDefaultValues = a.getBoolean(R.styleable.RangeSeekBar_activateOnDefaultValues, true);
        } finally {
            a.recycle();
        }
    }

    Resources resources = getResources();
    int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 18, resources.getDisplayMetrics());

    if (thumbImage == null) {
        thumbImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        Drawable thumbDrawableNormal = getResources().getDrawable(thumbNormal);
        thumbDrawableNormal.setBounds(0, 0, px, px);
        thumbDrawableNormal.draw(new Canvas(thumbImage));
    }
    if (thumbPressedImage == null) {
        Drawable thumbDrawablePressed = getResources().getDrawable(thumbPressed);
        thumbDrawablePressed.setBounds(0, 0, px, px);
        thumbPressedImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        thumbDrawablePressed.draw(new Canvas(thumbPressedImage));
    }
    if (thumbDisabledImage == null) {
        Drawable thumbDrawableDisabled = getResources().getDrawable(thumbDisabled);
        thumbDrawableDisabled.setBounds(0, 0, px, px);
        thumbDisabledImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        thumbDrawableDisabled.draw(new Canvas(thumbDisabledImage));
    }

    mThumbHalfWidth = 0.5f * thumbImage.getWidth();
    mThumbHalfHeight = 0.5f * thumbImage.getHeight();

    setValuePrimAndNumberType();

    mTextSize = PixelUtil.spToPx(context, DEFAULT_TEXT_SIZE_IN_SP);
    mDistanceToTop = PixelUtil.dpToPx(context, DEFAULT_TEXT_DISTANCE_TO_TOP_IN_DP);
    mTextOffset = !mShowTextAboveThumbs ? 0
            : this.mTextSize + PixelUtil.dpToPx(context, DEFAULT_TEXT_DISTANCE_TO_BUTTON_IN_DP)
                    + this.mDistanceToTop;

    mRect = new RectF(padding, mTextOffset + mThumbHalfHeight - barHeight / 2, getWidth() - padding,
            mTextOffset + mThumbHalfHeight + barHeight / 2);

    // make RangeSeekBar focusable. This solves focus handling issues in case EditText widgets are being used along with the RangeSeekBar within ScrollViews.
    setFocusable(true);
    setFocusableInTouchMode(true);
    mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    if (mThumbShadow) {
        // We need to remove hardware acceleration in order to blur the shadow
        setLayerType(LAYER_TYPE_SOFTWARE, null);
        shadowPaint.setColor(thumbShadowColor);
        shadowPaint.setMaskFilter(new BlurMaskFilter(mThumbShadowBlur, BlurMaskFilter.Blur.NORMAL));
        mThumbShadowPath = new Path();
        mThumbShadowPath.addCircle(0, 0, mThumbHalfHeight, Path.Direction.CW);
    }
}

From source file:com.digitalvotingpass.camera.CameraFragment.java

/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 *//*from   w w w .j a  v  a2 s. c o m*/
public void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);
    overlay.setRect(CameraFragmentUtil.getScanRect(scanSegment));
}

From source file:com.sflib.CustomView.baseview.RoundRecPagerSlidingTabStrip.java

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

    if (isInEditMode() || tabCount == 0) {
        return;//ww w  . j ava  2 s.com
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, doRefresh interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }
    float indicator_top = getPaddingTop();
    float indicator_botom = currentTab.getHeight() + indicator_top;
    float indicator_left = lineLeft + getPaddingLeft();
    //        L.info(this,"indicator_left: "+indicator_left+" lineLeft: "+lineLeft+" padding: "+currentTab.getPaddingLeft()+" currentPositionOffset: "+currentPositionOffset);
    RectF indicatorRec = new RectF(indicator_left - indicatorLeftRightPadding + tabPadding,
            indicator_top - indicatorTopBottomPadding, lineRight + indicatorLeftRightPadding - tabPadding,
            indicator_botom + indicatorTopBottomPadding);
    canvas.drawRoundRect(indicatorRec, indicatorRectCorner, indicatorRectCorner, rectPaint);

    // draw underline
    rectPaint.setColor(underlineColor);
    RectF rect = new RectF(0, height - underlineHeight, tabsContainer.getWidth(), height);
    canvas.drawRect(rect, rectPaint);
    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}

From source file:de.vanita5.twittnuker.view.ShapedImageView.java

private void updateShadowBitmap() {
    if (USE_OUTLINE)
        return;/*from  w  w  w .j  ava 2  s. c o  m*/
    final int width = getWidth(), height = getHeight();
    if (width <= 0 || height <= 0)
        return;
    final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(),
            contentRight = width - getPaddingRight(), contentBottom = height - getPaddingBottom();
    final int contentWidth = contentRight - contentLeft, contentHeight = contentBottom - contentTop;
    final float radius = mShadowRadius, dy = radius * 1.5f / 2;
    final int size = Math.round(Math.min(contentWidth, contentHeight) + radius * 2);
    mShadowBitmap = Bitmap.createBitmap(size, Math.round(size + dy), Config.ARGB_8888);
    Canvas canvas = new Canvas(mShadowBitmap);
    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setShadowLayer(radius, 0, radius * 1.5f / 2, SHADOW_START_COLOR);
    final RectF rect = new RectF(radius, radius, size - radius, size - radius);
    canvas.drawOval(rect, paint);
    paint.setShadowLayer(0, 0, 0, 0);
    paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
    canvas.drawOval(rect, paint);
    invalidate();
}

From source file:ac.robinson.paperchains.PaperChainsActivity.java

private void addAudioRects() {
    for (AudioAreaHolder holder : mAudioAreas) {
        // convert grid-based coordinates to image-based coordinates, accounting for image rotation/inversion by
        // making sure to use the min/max values of each coordinate
        Rect rect = holder.serverRect;/*from w  ww  .ja  v a2s.c  o  m*/
        PointF leftTop = QRImageParser.getImagePosition(mImageParameters, new PointF(rect.left, rect.top));
        PointF rightBottom = QRImageParser.getImagePosition(mImageParameters,
                new PointF(rect.right, rect.bottom));
        RectF displayRect = new RectF(Math.min(leftTop.x, rightBottom.x), Math.min(leftTop.y, rightBottom.y),
                Math.max(rightBottom.x, leftTop.x), Math.max(leftTop.y, rightBottom.y));
        Rect imageRect = new Rect();
        displayRect.roundOut(imageRect);

        holder.setImageRect(imageRect);
        mImageView.addAudioAreaRect(imageRect);
    }
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

private void drawCenterDot(Canvas canvas, int width, int height) {
    final float centerX = (width / 2.0f);
    final float centerY = (height / 2.0f);
    final float radius = mInnerRadius;
    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));/*  ww  w  .j av a 2  s.c  om*/

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(mDotFillColor);
    mPaint.setShadowLayer(mTextShadowRadius, 0, 0, mTextShadowColor);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    contractBounds(dotBounds, (DOT_STROKE_WIDTH / 2));
    mPaint.setStrokeWidth(DOT_STROKE_WIDTH);
    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(mDotStrokeColor);
    mPaint.setPathEffect(mDotPathEffect);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setPathEffect(null);
}