create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / chart / PieSegment.java
1 /**
2  * Copyright (C) 2009 - 2012 SC 4ViewSoft SRL
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 package org.achartengine.chart;
17
18 import java.io.Serializable;
19
20 /**
21  * Holds An PieChart Segment
22  */
23 public class PieSegment implements Serializable {
24   private float mStartAngle;
25
26   private float mEndAngle;
27
28   private int mDataIndex;
29
30   private float mValue;
31
32   public PieSegment(int dataIndex, float value, float startAngle, float angle) {
33     mStartAngle = startAngle;
34     mEndAngle = angle + startAngle;
35     mDataIndex = dataIndex;
36     mValue = value;
37   }
38
39   /**
40    * Checks if angle falls in segment.
41    * 
42    * @param angle
43    * @return true if in segment, false otherwise.
44    */
45   public boolean isInSegment(double angle) {
46     return angle >= mStartAngle && angle <= mEndAngle;
47   }
48
49   protected float getStartAngle() {
50     return mStartAngle;
51   }
52
53   protected float getEndAngle() {
54     return mEndAngle;
55   }
56
57   protected int getDataIndex() {
58     return mDataIndex;
59   }
60
61   protected float getValue() {
62     return mValue;
63   }
64
65   public String toString() {
66     return "mDataIndex=" + mDataIndex + ",mValue=" + mValue + ",mStartAngle=" + mStartAngle
67         + ",mEndAngle=" + mEndAngle;
68   }
69
70 }