Code example for RectF

Methods: centerX, centerY, height, width

0
    /** 
     * Returns center x-coordinate of this arc shape. 
     * @return center x-coordinate of this arc shape 
     */ 
    public float getCenterX() { 
        return mOval.centerX();
    } 
     
    /** 
     * Returns center y-coordinate of this arc shape. 
     * @return center y-coordinate of this arc shape 
     */ 
    public float getCenterY() { 
        return mOval.centerY();
    } 
     
    /** 
     * Returns start angle of the arc in degrees. 
     * @return The start angle of the arc in degrees 
     */ 
    public float getAngleStart() { 
        return mStartAngle;
    } 
 
    /** 
     * Sets start angle of the arc in degrees. 
     * @param degree The start angle of the arc in degrees 
     */ 
    public void setAngleStart(float degree) {
        this.mStartAngle = degree;
        update(); 
    } 
 
    /** 
     * Returns angle extent of the arc in degrees. 
     * @return The angle extent of the arc in degrees 
     */ 
    public float getAngleExtent() { 
        return mAngleExtent;
    } 
 
    /** 
     * Sets angle extent of the arc in degrees. 
     * @param degree The angle extent of the arc in degrees 
     */ 
    public void setAngleExtent(float degree) {
        this.mAngleExtent = degree;
        update(); 
    } 
 
    /** 
     * Gets coordinate of arc start point. 
     * @return The coordinate of arc start point 
     */ 
    public PointF getStartPoint() {
        return new PointF(mStartPoint.x, mStartPoint.y);
    } 
 
    /** 
     * Gets coordinate of arc end point. 
     * @return The coordinate of arc end point 
     */ 
    public PointF getEndPoint() {
        return new PointF(mEndPoint.x, mEndPoint.y);
    } 
 
    /** 
     * Returns true, if include the center of the oval in the arc, and close it if it is being stroked. 
     * @return mUseCenter If true, include the center of the oval in the arc, and close it if it is being stroked. 
     */ 
    public boolean isUseCenter() { 
        return mUseCenter;
    } 
     
    /** 
     * Sets mUseCenter of arc shape. 
     * @param useCenter If true, include the center of the oval in the arc, and close it if it is being stroked. 
     */ 
    public void setUseCenter(boolean useCenter) {
        this.mUseCenter = useCenter;
    } 
     
    /** 
     * Updates the internal data required to draw. 
     */ 
    private void update() { 
        mPath.reset();
         
        mStartPoint.x = (float)(Math.sin(Math.toRadians(mStartAngle + 90.0)) * (mOval.width() / 2.0)) + getCenterX();
        mStartPoint.y = (float)(-Math.cos(Math.toRadians(mStartAngle + 90.0)) * (mOval.height() / 2.0)) + getCenterY();
        mEndPoint.x = (float)(Math.sin(Math.toRadians(mStartAngle + mAngleExtent + 90.0)) * (mOval.width() / 2.0)) + getCenterX();
        mEndPoint.y = (float)(-Math.cos(Math.toRadians(mStartAngle + mAngleExtent + 90.0)) * (mOval.height() / 2.0)) + getCenterY();
         
        mPath.arcTo(mOval, mStartAngle, mAngleExtent);
        if (mUseCenter) {
            mPath.lineTo(mOval.centerX(), mOval.centerY());
        } 
        mPath.close();
        mRegion = new Region((int)mOval.left, (int)mOval.top, (int) mOval.right, (int) mOval.bottom);
        mRegion.setPath(mPath, mRegion);
    }