1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.graphics.drawable.shapes; 18 19 import android.graphics.Canvas; 20 import android.graphics.Outline; 21 import android.graphics.Paint; 22 23 /** 24 * Creates an arc shape. The arc shape starts at a specified 25 * angle and sweeps clockwise, drawing slices of pie. 26 * The arc can be drawn to a Canvas with its own draw() method, 27 * but more graphical control is available if you instead pass 28 * the ArcShape to a {@link android.graphics.drawable.ShapeDrawable}. 29 */ 30 public class ArcShape extends RectShape { 31 private float mStart; 32 private float mSweep; 33 34 /** 35 * ArcShape constructor. 36 * 37 * @param startAngle the angle (in degrees) where the arc begins 38 * @param sweepAngle the sweep angle (in degrees). Anything equal to or 39 * greater than 360 results in a complete circle/oval. 40 */ ArcShape(float startAngle, float sweepAngle)41 public ArcShape(float startAngle, float sweepAngle) { 42 mStart = startAngle; 43 mSweep = sweepAngle; 44 } 45 46 @Override draw(Canvas canvas, Paint paint)47 public void draw(Canvas canvas, Paint paint) { 48 canvas.drawArc(rect(), mStart, mSweep, true, paint); 49 } 50 51 @Override getOutline(Outline outline)52 public void getOutline(Outline outline) { 53 // Since we don't support concave outlines, arc shape does not attempt 54 // to provide an outline. 55 } 56 } 57 58