001 package com.google.gwt.maps.client.controls;
002
003 /**
004 * Identifiers used to specify the placement of controls on the map. Controls are positioned relative to other controls in the same layout position. Controls that are added first are positioned closer to the edge of the map.<br>
005 * <br>
006 * <table border="1px" padding="0px">
007 * <col width="33,3%"/><col width="33,3%"/><col width="33,3%"/>
008 * <thead><tbody>
009 * <tbody>
010 * <tr>
011 * <td>TL</td>
012 * <td>TC</td>
013 * <td>TR</td>
014 * </tr>
015 * <tr>
016 * <td>LT</td>
017 * <td></td>
018 * <td>RT</td>
019 * </tr>
020 * <tr>
021 * <td> </td>
022 * <td> </td>
023 * <td> </td>
024 * </tr>
025 * <tr>
026 * <td>LC</td>
027 * <td></td>
028 * <td>RC</td>
029 * </tr>
030 * <tr>
031 * <td> </td>
032 * <td> </td>
033 * <td> </td>
034 * </tr>
035 * <tr>
036 * <td>LB</td>
037 * <td></td>
038 * <td>LB</td>
039 * </tr>
040 * <tr>
041 * <td>BL</td>
042 * <td>BC</td>
043 * <td>BR</td>
044 * </tr>
045 * </tbody>
046 * </table>
047 * <br>
048 * Elements in the top or bottom row flow towards the middle. Elements at the left or right sides flow downwards.
049 * <br><br>
050 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#ControlPosition">ControlPosition API Doc</a>
051 */
052 public enum ControlPosition {
053
054 /**
055 * javascript constant numbers - reverse engineered
056 BOTTOM_CENTER=11
057 BOTTOM_LEFT=10
058 BOTTOM_RIGHT=12
059 LEFT_BOTTOM=6
060 LEFT_CENTER=4
061 LEFT_TOP=5
062 RIGHT_BOTTOM=9
063 RIGHT_CENTER=8
064 RIGHT_TOP=7
065 TOP_CENTER=2
066 TOP_LEFT=1
067 TOP_RIGHT=3
068 */
069
070 /**
071 * Elements are positioned in the center of the bottom row.
072 */
073 BOTTOM_CENTER(11),
074
075 /**
076 * Elements are positioned in the bottom left and flow towards the middle. Elements are positioned to the right of the Google logo.
077 */
078 BOTTOM_LEFT(10),
079
080 /**
081 * Elements are positioned in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
082 */
083 BOTTOM_RIGHT(12),
084
085 /**
086 * Elements are positioned on the left, above bottom-left elements, and flow upwards.
087 */
088 LEFT_BOTTOM(6),
089
090 /**
091 * Elements are positioned in the center of the left side.
092 */
093 LEFT_CENTER(4),
094
095 /**
096 * Elements are positioned on the left, below top-left elements, and flow downwards.
097 */
098 LEFT_TOP(5),
099
100 /**
101 * Elements are positioned on the right, above bottom-right elements, and flow upwards.
102 */
103 RIGHT_BOTTOM(9),
104
105 /**
106 * Elements are positioned in the center of the right side.
107 */
108 RIGHT_CENTER(8),
109
110 /**
111 * Elements are positioned on the right, below top-right elements, and flow downwards.
112 */
113 RIGHT_TOP(7),
114
115 /**
116 * Elements are positioned in the center of the top row.
117 */
118 TOP_CENTER(2),
119
120 /**
121 * Elements are positioned in the top left and flow towards the middle.
122 */
123 TOP_LEFT(1),
124
125 /**
126 * Elements are positioned in the top right and flow towards the middle.
127 */
128 TOP_RIGHT(3);
129
130 /**
131 * javascript constant value
132 */
133 private int value;
134
135 /**
136 * Elements in the top or bottom row flow towards the middle. Elements at the left or right sides flow downwards.
137 * @param value javascript constant value
138 */
139 ControlPosition(int value) {
140 this.value = value;
141 }
142
143 /**
144 * returns enum name
145 */
146 public String getName() {
147 return name();
148 }
149
150 /**
151 * returns javascript constant value
152 */
153 public int value() {
154 return value;
155 }
156
157 public String toString() {
158 return name() + "(" + value + ")";
159 }
160
161 /**
162 * reconstruct from position from javascript constant value
163 * @param value javascript constant value
164 */
165 public static ControlPosition fromValue(int value) {
166 ControlPosition r = null;
167 switch (value) {
168 case 1:
169 r = TOP_LEFT;
170 break;
171 case 2:
172 r = TOP_CENTER;
173 break;
174 case 3:
175 r = TOP_RIGHT;
176 break;
177 case 4:
178 r = LEFT_CENTER;
179 break;
180 case 5:
181 r = LEFT_TOP;
182 break;
183 case 6:
184 r = LEFT_BOTTOM;
185 break;
186 case 7:
187 r = RIGHT_TOP;
188 break;
189 case 8:
190 r = RIGHT_CENTER;
191 break;
192 case 9:
193 r = RIGHT_BOTTOM;
194 break;
195 case 10:
196 r = BOTTOM_LEFT;
197 break;
198 case 11:
199 r = BOTTOM_CENTER;
200 break;
201 case 12:
202 r = BOTTOM_RIGHT;
203 break;
204 }
205 return r;
206 }
207
208 }
209