create changelog entry
[debian/openrocket] / android-libraries / achartengine / src / org / achartengine / chart / PointStyle.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 /**
19  * The chart point style enumerator.
20  */
21 public enum PointStyle {
22   X("x"), CIRCLE("circle"), TRIANGLE("triangle"), SQUARE("square"), DIAMOND("diamond"), POINT(
23       "point");
24
25   /** The point shape name. */
26   private String mName;
27
28   /**
29    * The point style enum constructor.
30    * 
31    * @param name the name
32    */
33   private PointStyle(String name) {
34     mName = name;
35   }
36
37   /**
38    * Returns the point shape name.
39    * 
40    * @return the point shape name
41    */
42   public String getName() {
43     return mName;
44   }
45
46   /**
47    * Returns the point shape name.
48    * 
49    * @return the point shape name
50    */
51   public String toString() {
52     return getName();
53   }
54
55   /**
56    * Return the point shape that has the provided symbol.
57    * 
58    * @param name the point style name
59    * @return the point shape
60    */
61   public static PointStyle getPointStyleForName(String name) {
62     PointStyle pointStyle = null;
63     PointStyle[] styles = values();
64     int length = styles.length;
65     for (int i = 0; i < length && pointStyle == null; i++) {
66       if (styles[i].mName.equals(name)) {
67         pointStyle = styles[i];
68       }
69     }
70     return pointStyle;
71   }
72
73   /**
74    * Returns the point shape index based on the given name.
75    * 
76    * @return the point shape index
77    */
78   public static int getIndexForName(String name) {
79     int index = -1;
80     PointStyle[] styles = values();
81     int length = styles.length;
82     for (int i = 0; i < length && index < 0; i++) {
83       if (styles[i].mName.equals(name)) {
84         index = i;
85       }
86     }
87     return Math.max(0, index);
88   }
89
90 }