当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.getClipBounds方法代码示例

本文整理汇总了Java中android.graphics.Canvas.getClipBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.getClipBounds方法的具体用法?Java Canvas.getClipBounds怎么用?Java Canvas.getClipBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.getClipBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  canvas.getClipBounds(mRect);
  int top = mRect.top;
  int left = mRect.left;
  int width = mRect.width();
  int height = mRect.height();
  if (mRenderer.isInScroll()) {
    top = 0;
    left = 0;
    width = getMeasuredWidth();
    height = getMeasuredHeight();
  }
  mChart.draw(canvas, left, top, width, height, mPaint);
  if (mRenderer != null && mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible()) {
    mPaint.setColor(ZOOM_BUTTONS_COLOR);
    zoomSize = Math.max(zoomSize, Math.min(width, height) / 7);
    mZoomR.set(left + width - zoomSize * 3, top + height - zoomSize * 0.775f, left + width, top
        + height);
    canvas.drawRoundRect(mZoomR, zoomSize / 3, zoomSize / 3, mPaint);
    float buttonY = top + height - zoomSize * 0.625f;
    canvas.drawBitmap(zoomInImage, left + width - zoomSize * 2.75f, buttonY, null);
    canvas.drawBitmap(zoomOutImage, left + width - zoomSize * 1.75f, buttonY, null);
    canvas.drawBitmap(fitZoomImage, left + width - zoomSize * 0.75f, buttonY, null);
  }
  mDrawn = true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:29,代码来源:GraphicalView.java

示例2: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
    if (mClipRegion == 0) {
        super.onDraw(canvas);
    } else {
        canvas.getClipBounds(tempRect);
        final float clipWidth = tempRect.width() * mClipRegion;
        final int saveCount = canvas.save();


        if (mIsRtl) {
            canvas.clipRect(tempRect.left, tempRect.top, tempRect.right - clipWidth, tempRect.bottom);
        } else {
            canvas.clipRect(tempRect.left + clipWidth, tempRect.top, tempRect.right, tempRect.bottom);
        }
        super.onDraw(canvas);
        canvas.restoreToCount(saveCount);
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:20,代码来源:AnimatedProgressBar.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.getClipBounds(mCanvasClipBounds);

    int linesCount = mCanvasClipBounds.width() / (mProgressLineWidth + mProgressLineMargin);
    float deltaX = (mTotalScrollDistance) % (float) (mProgressLineMargin + mProgressLineWidth);

    mProgressLinePaint.setColor(getResources().getColor(R.color.ucrop_color_progress_wheel_line));
    for (int i = 0; i < linesCount; i++) {
        if (i < (linesCount / 4)) {
            mProgressLinePaint.setAlpha((int) (255 * (i / (float) (linesCount / 4))));
        } else if (i > (linesCount * 3 / 4)) {
            mProgressLinePaint.setAlpha((int) (255 * ((linesCount - i) / (float) (linesCount / 4))));
        } else {
            mProgressLinePaint.setAlpha(255);
        }
        canvas.drawLine(
                -deltaX + mCanvasClipBounds.left + i * (mProgressLineWidth + mProgressLineMargin),
                mCanvasClipBounds.centerY() - mProgressLineHeight / 4.0f,
                -deltaX + mCanvasClipBounds.left + i * (mProgressLineWidth + mProgressLineMargin),
                mCanvasClipBounds.centerY() + mProgressLineHeight / 4.0f, mProgressLinePaint);
    }

    mProgressLinePaint.setColor(mMiddleLineColor);
    canvas.drawLine(mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() - mProgressLineHeight / 2.0f, mCanvasClipBounds.centerX(), mCanvasClipBounds.centerY() + mProgressLineHeight / 2.0f, mProgressLinePaint);

}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:29,代码来源:HorizontalProgressWheelView.java

示例4: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    paint.setColor(dotColor);
    canvas.save();
    canvas.getClipBounds(clipRect);
    clipRect.inset(-targetLeft, 0);
    canvas.translate(-targetLeft, 0);
    canvas.drawCircle(centerX, targetTop + centerY, radius * radiusScale, paint);
    canvas.restore();
}
 
开发者ID:uDevel,项目名称:widgetlab,代码行数:11,代码来源:BouncingSlidingDotView.java

示例5: drawShadow

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawShadow(Canvas canvas) {
    if (shadowDrawable != null) {

        Rect newRect = canvas.getClipBounds();
        Log.d(TAG,"ShadowParentView has blur! " + newRect);
        newRect.inset(-shadowPadding, -shadowPadding);
        canvas.clipRect (newRect, Region.Op.REPLACE);

        shadowDrawable.draw(canvas);
    }
}
 
开发者ID:wix,项目名称:react-native-andorid-shadow,代码行数:12,代码来源:ShadowParentView.java

示例6: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isSelected()) {
        canvas.getClipBounds(mCanvasClipBounds);
        canvas.drawCircle((mCanvasClipBounds.right - mCanvasClipBounds.left) / 2.0f, mCanvasClipBounds.bottom - mDotSize,
                mDotSize / 2, mDotPaint);
    }
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:11,代码来源:AspectRatioTextView.java

示例7: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isSelected()) {
        canvas.getClipBounds(this.mCanvasClipBounds);
        canvas.drawCircle(((float) (this.mCanvasClipBounds.right - this.mCanvasClipBounds
                .left)) / 2.0f, (float) (this.mCanvasClipBounds.bottom - this.mDotSize),
                (float) (this.mDotSize / 2), this.mDotPaint);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:AspectRatioTextView.java

示例8: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
    canvas.save();
    Rect bounds = canvas.getClipBounds();

    // bottom etched line.
    if (mBottomEtchedPaint != null) shape.draw(canvas, mBottomEtchedPaint);
    canvas.restore();
    canvas.save();

    // separator.
    canvas.concat(getSeparatorPaintMatrix(bounds));
    shape.draw(canvas, mSeparatorPaint);
    canvas.restore();
    canvas.save();

    // top etched line.
    canvas.concat(getTopEtchedPaintMatrix(bounds));
    if (mTopEtchedPaint != null) shape.draw(canvas, mTopEtchedPaint);
    canvas.restore();
    canvas.save();

    // background.
    canvas.concat(getBackgroundPaintMatrix(bounds));
    shape.draw(canvas, mBackgroundPaint);
    canvas.restore();
    canvas.save();

    // selected.
    canvas.concat(getSelectedPaintMatrix(bounds));
    if (mSelectedPaint != null) {

        // we'll set the selected color on onDraw event since we don't know drawable height up to here.
        Shader shader = new LinearGradient(0, 0, 0, mRowHeight, mStartColor, mEndColor, Shader.TileMode.MIRROR);
        mSelectedPaint.setShader(shader);

        shape.draw(canvas, mSelectedPaint);
    }
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:40,代码来源:ATableViewCellDrawable.java

示例9: configureBounds

import android.graphics.Canvas; //导入方法依赖的package包/类
private void configureBounds(Canvas canvas) {
    // I have discovered a truly marvelous explanation of this,
    // which this comment space is too narrow to contain. :)
    // If you want to understand what's going on here,
    // See http://www.joooooooooonhokim.com/?p=289
    Rect clipBounds = canvas.getClipBounds();
    Matrix canvasMatrix = canvas.getMatrix();

    if (ScaleType.CENTER == mScaleType) {
        mBounds.set(clipBounds);
    } else if (ScaleType.CENTER_CROP == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_XY == mScaleType) {
        Matrix m = new Matrix();
        m.setRectToRect(mBitmapRect, new RectF(clipBounds), Matrix.ScaleToFit.FILL);
        mBitmapShader.setLocalMatrix(m);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
               || ScaleType.FIT_CENTER == mScaleType || ScaleType.CENTER_INSIDE == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    } else if (ScaleType.MATRIX == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    }
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:28,代码来源:SelectableRoundedImageView.java

示例10: addFrame

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 图片增加边框
 * 
 * @author 2013-10-12 下午3:58:28
 * @param bitmap
 * @param color
 * @return Bitmap
 */
public static Bitmap addFrame(Bitmap bitmap, int color)
{
    Bitmap bitmap2 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap2);
    Rect rect = canvas.getClipBounds();
    rect.bottom--;
    rect.right--;
    Paint recPaint = new Paint();
    recPaint.setColor(color);
    recPaint.setStyle(Paint.Style.STROKE);
    canvas.drawRect(rect, recPaint);
    canvas.drawBitmap(bitmap, 0, 0, null);
    return bitmap2;
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:23,代码来源:MIP_BitmapUtils.java

示例11: drawChild

import android.graphics.Canvas; //导入方法依赖的package包/类
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    boolean result;
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    int save = canvas.save(2);
    if (!(!this.mCanSlide || lp.slideable || this.mSlideableView == null)) {
        canvas.getClipBounds(this.mTmpRect);
        if (isLayoutRtlSupport()) {
            this.mTmpRect.left = Math.max(this.mTmpRect.left, this.mSlideableView.getRight());
        } else {
            this.mTmpRect.right = Math.min(this.mTmpRect.right, this.mSlideableView.getLeft());
        }
        canvas.clipRect(this.mTmpRect);
    }
    if (VERSION.SDK_INT >= 11) {
        result = super.drawChild(canvas, child, drawingTime);
    } else if (!lp.dimWhenOffset || this.mSlideOffset <= 0.0f) {
        if (child.isDrawingCacheEnabled()) {
            child.setDrawingCacheEnabled(false);
        }
        result = super.drawChild(canvas, child, drawingTime);
    } else {
        if (!child.isDrawingCacheEnabled()) {
            child.setDrawingCacheEnabled(true);
        }
        Bitmap cache = child.getDrawingCache();
        if (cache != null) {
            canvas.drawBitmap(cache, (float) child.getLeft(), (float) child.getTop(), lp.dimPaint);
            result = false;
        } else {
            Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache");
            result = super.drawChild(canvas, child, drawingTime);
        }
    }
    canvas.restoreToCount(save);
    return result;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:SlidingPaneLayout.java

示例12: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (mGalaxy == null) {
        return;
    }

    if (mAnimated) {
        mAnimationTime = Math.abs(System.currentTimeMillis() - mAnimationStartTime) % ANIMATION_DURATION;
    }

    canvas.save();
    // Translate top-left point of current view (canvas coordinates) towards left and up (right and down if negative)
    canvas.translate(-mCanvasScrollX, -mCanvasScrollY);
    // Scale around a pivot center
    canvas.scale(mCanvasScale, mCanvasScale, mCanvasPivotX, mCanvasPivotY);
    // Get bounds of current showed view (canvas coordinates)
    canvas.getClipBounds(mBoundsView);

    // Clips the drawing operations to the window
    //canvas.clipRect(mBoundsView);

    // [...] stuff drawn with matrix transformations
    drawGrid(canvas);
    drawPlanets(canvas);
    drawFleets(canvas);
    drawDragShips(canvas);
    drawPointer(canvas);

    canvas.restore();
    // [...] stuff drawn without matrix transformations, as an overlay

    if (mAnimated) {
        postInvalidateDelayed(1000 / ANIMATION_FPS);
    }

}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:39,代码来源:GalaxyView.java

示例13: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    final Rect r = new Rect(getBounds());
    if (canvas.getClipBounds(sTempRect) && !Rect.intersects(sTempRect, r)) {
        // The draw region has been clipped.
        return;
    }
    if (mIndicatorRectDirty) {
        initIndicatorRect();
    }
    final float iconScale;

    if ((mAnimationProgress >= ANIMATION_PROGRESS_STARTED)
            && (mAnimationProgress < ANIMATION_PROGRESS_COMPLETED)) {
        mPaint.setAlpha((int) ((1 - mAnimationProgress) * 255));
        mBgDrawable.setAlpha(mPaint.getAlpha());
        mBgDrawable.draw(canvas);
        canvas.drawOval(mIndicatorRect, mPaint);

        iconScale = ICON_SCALE_FACTOR + (1 - ICON_SCALE_FACTOR) * mAnimationProgress;
    } else if (mAnimationProgress == ANIMATION_PROGRESS_STOPPED) {
        mPaint.setAlpha(255);
        iconScale = ICON_SCALE_FACTOR;
        mBgDrawable.setAlpha(255);
        mBgDrawable.draw(canvas);

        if (mProgress >= 100) {
            canvas.drawOval(mIndicatorRect, mPaint);
        } else if (mProgress > 0) {
            canvas.drawArc(mIndicatorRect, -90, mProgress * 3.6f, false, mPaint);
        }
    } else {
        iconScale = 1;
    }

    canvas.save();
    canvas.scale(iconScale, iconScale, r.exactCenterX(), r.exactCenterY());
    mIcon.draw(canvas);
    canvas.restore();
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:41,代码来源:PreloadIconDrawable.java

示例14: drawChild

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    boolean result;
    final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);

    if (mSlideableView != child) { // if main view
        // Clip against the slider; no sense drawing what will immediately be covered,
        // Unless the panel is set to overlay content
        canvas.getClipBounds(mTmpRect);
        if (!mOverlayContent) {
            if (mIsSlidingUp) {
                mTmpRect.bottom = Math.min(mTmpRect.bottom, mSlideableView.getTop());
            } else {
                mTmpRect.top = Math.max(mTmpRect.top, mSlideableView.getBottom());
            }
        }
        if (mClipPanel) {
            canvas.clipRect(mTmpRect);
        }

        result = super.drawChild(canvas, child, drawingTime);

        if (mCoveredFadeColor != 0 && mSlideOffset > 0) {
            final int baseAlpha = (mCoveredFadeColor & 0xff000000) >>> 24;
            final int imag = (int) (baseAlpha * mSlideOffset);
            final int color = imag << 24 | (mCoveredFadeColor & 0xffffff);
            mCoveredFadePaint.setColor(color);
            canvas.drawRect(mTmpRect, mCoveredFadePaint);
        }
    } else {
        result = super.drawChild(canvas, child, drawingTime);
    }

    canvas.restoreToCount(save);

    return result;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:38,代码来源:SlidingUpPanelLayout.java

示例15: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
    protected void onDraw(Canvas canvas) {
//        if (isInEditMode()) {
//            canvas.drawColor(Color.BLACK);
//            return;
//        }
        //绘制轨道背景
        canvas.save();
        mPaint.setColor(mTrackBgColor);
        int trackLeft = getPaddingLeft();
        int trackTop = (getMeasuredHeight() - mTrackHeight) / 2;
        int trackRight = getMeasuredWidth() - getPaddingRight();
        int trackBottom = getMeasuredHeight() / 2 + mTrackHeight / 2;
        mTrackRectF.set(trackLeft, trackTop, trackRight, trackBottom);
        canvas.drawRoundRect(mTrackRectF, mTrackRadius, mTrackRadius, mPaint);
        canvas.restore();

        //第二进度
        if (secondProgress > 0) {
            canvas.save();
            mPaint.setColor(secondProgressColor);
            if (thumbType == THUMB_DEFAULT) {
                mTrackRectF.set(trackLeft, trackTop, trackLeft + secondProgress / getMaxProgress() * getMaxProgressLength(), trackBottom);
            } else if (thumbType == THUMB_CIRCLE) {
                mTrackRectF.set(trackLeft, trackTop, trackLeft + secondProgress / getMaxProgress() * getMaxProgressLength(), trackBottom);
            }
            canvas.drawRoundRect(mTrackRectF, mTrackRadius, mTrackRadius, mPaint);
            canvas.restore();
        }

        //绘制轨道
        canvas.save();
        mPaint.setColor(mTrackColor);
        if (thumbType == THUMB_DEFAULT) {
            mTrackRectF.set(trackLeft, trackTop, trackLeft + curProgress / getMaxProgress() * getMaxLength() + mThumbWidth / 2, trackBottom);
        } else if (thumbType == THUMB_CIRCLE) {
            mTrackRectF.set(trackLeft, trackTop, trackLeft + curProgress / getMaxProgress() * getMaxLength() + mThumbRadius / 2, trackBottom);
        }
        canvas.drawRoundRect(mTrackRectF, mTrackRadius, mTrackRadius, mPaint);
        canvas.restore();

        //绘制浮子
        updateProgress();
        //浮子外圈, 在touch状态下绘制
        if (isTouchDown && thumbType == THUMB_CIRCLE) {
            canvas.save();
            canvas.getClipBounds(clipBounds);
            clipBounds.inset(-mThumbRoundSize * 2, -mThumbRoundSize * 2);
            canvas.clipRect(clipBounds, Region.Op.REPLACE);
            mPaint.setColor(secondProgressColor);
            canvas.drawCircle(mProgressRectF.centerX(), mProgressRectF.centerY(),
                    mThumbRoundSize + mThumbRoundSize / 2, mPaint);
            canvas.restore();
        }
        //浮子
        canvas.save();
        mPaint.setColor(mThumbColor);
        if (thumbType == THUMB_DEFAULT) {
            canvas.drawRoundRect(mProgressRectF, mThumbRoundSize, mThumbRoundSize, mPaint);
        } else if (thumbType == THUMB_CIRCLE) {
            canvas.drawCircle(mProgressRectF.centerX(), mProgressRectF.centerY(), mThumbHeight / 2, mPaint);
        }
        canvas.restore();
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:65,代码来源:RSeekBar.java


注:本文中的android.graphics.Canvas.getClipBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。