87 |
*/ |
*/ |
88 |
public SizeRequirements() |
public SizeRequirements() |
89 |
{ |
{ |
90 |
// TODO |
this (0, 0, 0, 0.5F); |
91 |
} |
} |
92 |
|
|
93 |
/** |
/** |
101 |
*/ |
*/ |
102 |
public SizeRequirements(int min, int pref, int max, float align) |
public SizeRequirements(int min, int pref, int max, float align) |
103 |
{ |
{ |
104 |
// TODO |
minimum = min; |
105 |
|
preferred = pref; |
106 |
|
maximum = max; |
107 |
|
alignment = align; |
108 |
} |
} |
109 |
|
|
110 |
/** |
/** |
132 |
public static SizeRequirements |
public static SizeRequirements |
133 |
getTiledSizeRequirements(SizeRequirements[] children) |
getTiledSizeRequirements(SizeRequirements[] children) |
134 |
{ |
{ |
135 |
return null; // TODO |
SizeRequirements result = new SizeRequirements(); |
136 |
|
for (int i = 0; i < children.length; i++) |
137 |
|
{ |
138 |
|
result.minimum += children[i].minimum; |
139 |
|
result.preferred += children[i].preferred; |
140 |
|
result.maximum += children[i].maximum; |
141 |
|
} |
142 |
|
return result; |
143 |
} |
} |
144 |
|
|
145 |
/** |
/** |
172 |
* The calculated offset and span values for each component are then |
* The calculated offset and span values for each component are then |
173 |
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
174 |
* |
* |
175 |
|
* The components are placed in the forward direction, beginning with |
176 |
|
* an offset of 0. |
177 |
|
* |
178 |
* @param allocated the amount of allocated space |
* @param allocated the amount of allocated space |
179 |
* @param total the total size requirements of the components |
* @param total the total size requirements of the components |
180 |
* @param children the size requirement of each component |
* @param children the size requirement of each component |
184 |
public static void calculateTiledPositions(int allocated, |
public static void calculateTiledPositions(int allocated, |
185 |
SizeRequirements total, |
SizeRequirements total, |
186 |
SizeRequirements[] children, |
SizeRequirements[] children, |
187 |
int[] offset, int[] spans) |
int[] offsets, int[] spans) |
188 |
{ |
{ |
189 |
// TODO |
calculateTiledPositions(allocated, total, children, offsets, spans, true); |
190 |
} |
} |
191 |
|
|
192 |
/** |
/** |
202 |
* The calculated offset and span values for each component are then |
* The calculated offset and span values for each component are then |
203 |
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
204 |
* |
* |
205 |
|
* Depending on the value of <code>forward</code> the components are |
206 |
|
* placed in the forward direction (left-right or top-bottom), where |
207 |
|
* the offsets begin with 0, or in the reverse direction |
208 |
|
* (right-left or bottom-top). |
209 |
|
* |
210 |
|
* @param allocated the amount of allocated space |
211 |
|
* @param total the total size requirements of the components |
212 |
|
* @param children the size requirement of each component |
213 |
|
* @param offsets will hold the offset values for each component |
214 |
|
* @param spans will hold the span values for each component |
215 |
|
* @param forward whether the components should be placed in the forward |
216 |
|
* direction (left-right or top-bottom) or reverse direction |
217 |
|
* (right-left or bottom-top) |
218 |
|
*/ |
219 |
|
public static void calculateTiledPositions(int allocated, |
220 |
|
SizeRequirements total, |
221 |
|
SizeRequirements[] children, |
222 |
|
int[] offsets, int[] spans, |
223 |
|
boolean forward) |
224 |
|
{ |
225 |
|
if (forward) |
226 |
|
{ |
227 |
|
int offset = 0; |
228 |
|
for (int i = 0; i < children.length; i++) |
229 |
|
{ |
230 |
|
offsets[i] = offset; |
231 |
|
spans[i] = children[i].preferred; |
232 |
|
offset += children[i].preferred; |
233 |
|
} |
234 |
|
} |
235 |
|
else |
236 |
|
{ |
237 |
|
int offset = allocated; |
238 |
|
for (int i = 0; i < children.length; i++) |
239 |
|
{ |
240 |
|
offset -= children[i].preferred; |
241 |
|
offsets[i] = offset; |
242 |
|
spans[i] = children[i].preferred; |
243 |
|
} |
244 |
|
} |
245 |
|
} |
246 |
|
|
247 |
|
/** |
248 |
|
* Calculate the offsets and spans of the components, when they should |
249 |
|
* be placed end-to-end. |
250 |
|
* |
251 |
|
* You must specify the amount of allocated space in |
252 |
|
* <code>allocated</code>, the total size requirements of the set of |
253 |
|
* components in <code>total</code> (this can be calculated using |
254 |
|
* {@link #getTiledSizeRequirements} and the size requirements of the |
255 |
|
* components in <code>children</code>. |
256 |
|
* |
257 |
|
* The calculated offset and span values for each component are then |
258 |
|
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
259 |
|
* |
260 |
|
* The components are tiled in the forward direction, beginning with |
261 |
|
* an offset of 0. |
262 |
|
* |
263 |
|
* @param allocated the amount of allocated space |
264 |
|
* @param total the total size requirements of the components |
265 |
|
* @param children the size requirement of each component |
266 |
|
* @param offsets will hold the offset values for each component |
267 |
|
* @param spans will hold the span values for each component |
268 |
|
*/ |
269 |
|
public static void calculateAlignedPositions(int allocated, |
270 |
|
SizeRequirements total, |
271 |
|
SizeRequirements[] children, |
272 |
|
int[] offsets, int[] spans) |
273 |
|
{ |
274 |
|
calculateTiledPositions(allocated, total, children, offsets, spans, true); |
275 |
|
} |
276 |
|
|
277 |
|
/** |
278 |
|
* Calculate the offsets and spans of the components, when they should |
279 |
|
* be placed end-to-end. |
280 |
|
* |
281 |
|
* You must specify the amount of allocated space in |
282 |
|
* <code>allocated</code>, the total size requirements of the set of |
283 |
|
* components in <code>total</code> (this can be calculated using |
284 |
|
* {@link #getTiledSizeRequirements} and the size requirements of the |
285 |
|
* components in <code>children</code>. |
286 |
|
* |
287 |
|
* The calculated offset and span values for each component are then |
288 |
|
* stored in the arrays <code>offsets</code> and <code>spans</code>. |
289 |
|
* |
290 |
|
* Depending on the value of <code>forward</code> the components are |
291 |
|
* placed in the forward direction (left-right or top-bottom), where |
292 |
|
* the offsets begin with 0, or in the reverse direction |
293 |
|
* (right-left or bottom-top). |
294 |
|
* |
295 |
* @param allocated the amount of allocated space |
* @param allocated the amount of allocated space |
296 |
* @param total the total size requirements of the components |
* @param total the total size requirements of the components |
297 |
* @param children the size requirement of each component |
* @param children the size requirement of each component |
298 |
* @param offsets will hold the offset values for each component |
* @param offsets will hold the offset values for each component |
299 |
* @param spans will hold the span values for each component |
* @param spans will hold the span values for each component |
300 |
|
* @param forward whether the components should be placed in the forward |
301 |
|
* direction (left-right or top-bottom) or reverse direction |
302 |
|
* (right-left or bottom-top) |
303 |
*/ |
*/ |
304 |
public static void calculateAlignedPositions(int allocated, |
public static void calculateAlignedPositions(int allocated, |
305 |
SizeRequirements total, |
SizeRequirements total, |
306 |
SizeRequirements[] children, |
SizeRequirements[] children, |
307 |
int[] offset, int[] spans) |
int[] offset, int[] spans, |
308 |
|
boolean forward) |
309 |
{ |
{ |
310 |
// TODO |
// TODO |
311 |
} |
} |