e9f61461906a029bac7a26292f44e180c903b991
[jalviewjs.git] / site / j2s / javax / swing / text / BoxView.js
1 Clazz.declarePackage ("javax.swing.text");\r
2 Clazz.load (["javax.swing.text.CompositeView"], "javax.swing.text.BoxView", ["java.lang.IllegalArgumentException", "java.awt.Rectangle", "javax.swing.SizeRequirements", "javax.swing.text.Position"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.majorAxis = 0;\r
5 this.majorSpan = 0;\r
6 this.minorSpan = 0;\r
7 this.majorReqValid = false;\r
8 this.minorReqValid = false;\r
9 this.majorRequest = null;\r
10 this.minorRequest = null;\r
11 this.majorAllocValid = false;\r
12 this.majorOffsets = null;\r
13 this.majorSpans = null;\r
14 this.minorAllocValid = false;\r
15 this.minorOffsets = null;\r
16 this.minorSpans = null;\r
17 this.tempRect = null;\r
18 Clazz.instantialize (this, arguments);\r
19 }, javax.swing.text, "BoxView", javax.swing.text.CompositeView);\r
20 Clazz.makeConstructor (c$, \r
21 function (elem, axis) {\r
22 Clazz.superConstructor (this, javax.swing.text.BoxView, [elem]);\r
23 this.tempRect =  new java.awt.Rectangle ();\r
24 this.majorAxis = axis;\r
25 this.majorOffsets =  Clazz.newIntArray (0, 0);\r
26 this.majorSpans =  Clazz.newIntArray (0, 0);\r
27 this.majorReqValid = false;\r
28 this.majorAllocValid = false;\r
29 this.minorOffsets =  Clazz.newIntArray (0, 0);\r
30 this.minorSpans =  Clazz.newIntArray (0, 0);\r
31 this.minorReqValid = false;\r
32 this.minorAllocValid = false;\r
33 }, "javax.swing.text.Element,~N");\r
34 Clazz.defineMethod (c$, "getAxis", \r
35 function () {\r
36 return this.majorAxis;\r
37 });\r
38 Clazz.defineMethod (c$, "setAxis", \r
39 function (axis) {\r
40 var axisChanged = (axis != this.majorAxis);\r
41 this.majorAxis = axis;\r
42 if (axisChanged) {\r
43 this.preferenceChanged (null, true, true);\r
44 }}, "~N");\r
45 Clazz.defineMethod (c$, "layoutChanged", \r
46 function (axis) {\r
47 if (axis == this.majorAxis) {\r
48 this.majorAllocValid = false;\r
49 } else {\r
50 this.minorAllocValid = false;\r
51 }}, "~N");\r
52 Clazz.defineMethod (c$, "isLayoutValid", \r
53 function (axis) {\r
54 if (axis == this.majorAxis) {\r
55 return this.majorAllocValid;\r
56 } else {\r
57 return this.minorAllocValid;\r
58 }}, "~N");\r
59 Clazz.defineMethod (c$, "paintChild", \r
60 function (g, alloc, index) {\r
61 var child = this.getView (index);\r
62 child.paint (g, alloc);\r
63 }, "java.awt.Graphics,java.awt.Rectangle,~N");\r
64 Clazz.defineMethod (c$, "replace", \r
65 function (index, length, elems) {\r
66 Clazz.superCall (this, javax.swing.text.BoxView, "replace", [index, length, elems]);\r
67 var nInserted = (elems != null) ? elems.length : 0;\r
68 this.majorOffsets = this.updateLayoutArray (this.majorOffsets, index, nInserted);\r
69 this.majorSpans = this.updateLayoutArray (this.majorSpans, index, nInserted);\r
70 this.majorReqValid = false;\r
71 this.majorAllocValid = false;\r
72 this.minorOffsets = this.updateLayoutArray (this.minorOffsets, index, nInserted);\r
73 this.minorSpans = this.updateLayoutArray (this.minorSpans, index, nInserted);\r
74 this.minorReqValid = false;\r
75 this.minorAllocValid = false;\r
76 }, "~N,~N,~A");\r
77 Clazz.defineMethod (c$, "updateLayoutArray", \r
78 function (oldArray, offset, nInserted) {\r
79 var n = this.getViewCount ();\r
80 var newArray =  Clazz.newIntArray (n, 0);\r
81 System.arraycopy (oldArray, 0, newArray, 0, offset);\r
82 System.arraycopy (oldArray, offset, newArray, offset + nInserted, n - nInserted - offset);\r
83 return newArray;\r
84 }, "~A,~N,~N");\r
85 Clazz.defineMethod (c$, "forwardUpdate", \r
86 function (ec, e, a, f) {\r
87 var wasValid = this.isLayoutValid (this.majorAxis);\r
88 Clazz.superCall (this, javax.swing.text.BoxView, "forwardUpdate", [ec, e, a, f]);\r
89 if (wasValid && (!this.isLayoutValid (this.majorAxis))) {\r
90 var c = this.getContainer ();\r
91 if ((a != null) && (c != null)) {\r
92 var pos = e.getOffset ();\r
93 var index = this.getViewIndexAtPosition (pos);\r
94 var alloc = this.getInsideAllocation (a);\r
95 if (this.majorAxis == 0) {\r
96 alloc.x += this.majorOffsets[index];\r
97 alloc.width -= this.majorOffsets[index];\r
98 } else {\r
99 alloc.y += this.minorOffsets[index];\r
100 alloc.height -= this.minorOffsets[index];\r
101 }c.repaint (alloc.x, alloc.y, alloc.width, alloc.height);\r
102 }}}, "javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory");\r
103 Clazz.defineMethod (c$, "preferenceChanged", \r
104 function (child, width, height) {\r
105 var majorChanged = (this.majorAxis == 0) ? width : height;\r
106 var minorChanged = (this.majorAxis == 0) ? height : width;\r
107 if (majorChanged) {\r
108 this.majorReqValid = false;\r
109 this.majorAllocValid = false;\r
110 }if (minorChanged) {\r
111 this.minorReqValid = false;\r
112 this.minorAllocValid = false;\r
113 }Clazz.superCall (this, javax.swing.text.BoxView, "preferenceChanged", [child, width, height]);\r
114 }, "javax.swing.text.View,~B,~B");\r
115 Clazz.defineMethod (c$, "getResizeWeight", \r
116 function (axis) {\r
117 this.checkRequests (axis);\r
118 if (axis == this.majorAxis) {\r
119 if ((this.majorRequest.preferred != this.majorRequest.minimum) || (this.majorRequest.preferred != this.majorRequest.maximum)) {\r
120 return 1;\r
121 }} else {\r
122 if ((this.minorRequest.preferred != this.minorRequest.minimum) || (this.minorRequest.preferred != this.minorRequest.maximum)) {\r
123 return 1;\r
124 }}return 0;\r
125 }, "~N");\r
126 Clazz.defineMethod (c$, "setSpanOnAxis", \r
127 function (axis, span) {\r
128 if (axis == this.majorAxis) {\r
129 if (this.majorSpan != Clazz.floatToInt (span)) {\r
130 this.majorAllocValid = false;\r
131 }if (!this.majorAllocValid) {\r
132 this.majorSpan = Clazz.floatToInt (span);\r
133 this.checkRequests (this.majorAxis);\r
134 this.layoutMajorAxis (this.majorSpan, axis, this.majorOffsets, this.majorSpans);\r
135 this.majorAllocValid = true;\r
136 this.updateChildSizes ();\r
137 }} else {\r
138 if ((Clazz.floatToInt (span)) != this.minorSpan) {\r
139 this.minorAllocValid = false;\r
140 }if (!this.minorAllocValid) {\r
141 this.minorSpan = Clazz.floatToInt (span);\r
142 this.checkRequests (axis);\r
143 this.layoutMinorAxis (this.minorSpan, axis, this.minorOffsets, this.minorSpans);\r
144 this.minorAllocValid = true;\r
145 this.updateChildSizes ();\r
146 }}}, "~N,~N");\r
147 Clazz.defineMethod (c$, "updateChildSizes", \r
148 function () {\r
149 var n = this.getViewCount ();\r
150 if (this.majorAxis == 0) {\r
151 for (var i = 0; i < n; i++) {\r
152 var v = this.getView (i);\r
153 v.setSize (this.majorSpans[i], this.minorSpans[i]);\r
154 }\r
155 } else {\r
156 for (var i = 0; i < n; i++) {\r
157 var v = this.getView (i);\r
158 v.setSize (this.minorSpans[i], this.majorSpans[i]);\r
159 }\r
160 }});\r
161 Clazz.defineMethod (c$, "getSpanOnAxis", \r
162 function (axis) {\r
163 if (axis == this.majorAxis) {\r
164 return this.majorSpan;\r
165 } else {\r
166 return this.minorSpan;\r
167 }}, "~N");\r
168 Clazz.defineMethod (c$, "setSize", \r
169 function (width, height) {\r
170 this.layout (Math.max (0, Clazz.floatToInt (width - this.getLeftInset () - this.getRightInset ())), Math.max (0, Clazz.floatToInt (height - this.getTopInset () - this.getBottomInset ())));\r
171 }, "~N,~N");\r
172 Clazz.defineMethod (c$, "paint", \r
173 function (g, allocation) {\r
174 var alloc = (Clazz.instanceOf (allocation, java.awt.Rectangle)) ? allocation : allocation.getBounds ();\r
175 var n = this.getViewCount ();\r
176 var x = alloc.x + this.getLeftInset ();\r
177 var y = alloc.y + this.getTopInset ();\r
178 var clip = g.getClipBounds ();\r
179 for (var i = 0; i < n; i++) {\r
180 this.tempRect.x = x + this.getOffset (0, i);\r
181 this.tempRect.y = y + this.getOffset (1, i);\r
182 this.tempRect.width = this.getSpan (0, i);\r
183 this.tempRect.height = this.getSpan (1, i);\r
184 var trx0 = this.tempRect.x;\r
185 var trx1 = trx0 + this.tempRect.width;\r
186 var try0 = this.tempRect.y;\r
187 var try1 = try0 + this.tempRect.height;\r
188 var crx0 = clip.x;\r
189 var crx1 = crx0 + clip.width;\r
190 var cry0 = clip.y;\r
191 var cry1 = cry0 + clip.height;\r
192 if ((trx1 >= crx0) && (try1 >= cry0) && (crx1 >= trx0) && (cry1 >= try0)) {\r
193 this.paintChild (g, this.tempRect, i);\r
194 }}\r
195 }, "java.awt.Graphics,java.awt.Shape");\r
196 Clazz.defineMethod (c$, "getChildAllocation", \r
197 function (index, a) {\r
198 if (a != null) {\r
199 var ca = Clazz.superCall (this, javax.swing.text.BoxView, "getChildAllocation", [index, a]);\r
200 if ((ca != null) && (!this.isAllocationValid ())) {\r
201 var r = (Clazz.instanceOf (ca, java.awt.Rectangle)) ? ca : ca.getBounds ();\r
202 if ((r.width == 0) && (r.height == 0)) {\r
203 return null;\r
204 }}return ca;\r
205 }return null;\r
206 }, "~N,java.awt.Shape");\r
207 Clazz.defineMethod (c$, "modelToView", \r
208 function (pos, a, b) {\r
209 if (!this.isAllocationValid ()) {\r
210 var alloc = a.getBounds ();\r
211 this.setSize (alloc.width, alloc.height);\r
212 }return Clazz.superCall (this, javax.swing.text.BoxView, "modelToView", [pos, a, b]);\r
213 }, "~N,java.awt.Shape,javax.swing.text.Position.Bias");\r
214 Clazz.defineMethod (c$, "viewToModel", \r
215 function (x, y, a, bias) {\r
216 if (!this.isAllocationValid ()) {\r
217 var alloc = a.getBounds ();\r
218 this.setSize (alloc.width, alloc.height);\r
219 }return Clazz.superCall (this, javax.swing.text.BoxView, "viewToModel", [x, y, a, bias]);\r
220 }, "~N,~N,java.awt.Shape,~A");\r
221 Clazz.defineMethod (c$, "getAlignment", \r
222 function (axis) {\r
223 this.checkRequests (axis);\r
224 if (axis == this.majorAxis) {\r
225 return this.majorRequest.alignment;\r
226 } else {\r
227 return this.minorRequest.alignment;\r
228 }}, "~N");\r
229 Clazz.defineMethod (c$, "getPreferredSpan", \r
230 function (axis) {\r
231 this.checkRequests (axis);\r
232 var marginSpan = (axis == 0) ? this.getLeftInset () + this.getRightInset () : this.getTopInset () + this.getBottomInset ();\r
233 if (axis == this.majorAxis) {\r
234 return (this.majorRequest.preferred) + marginSpan;\r
235 } else {\r
236 return (this.minorRequest.preferred) + marginSpan;\r
237 }}, "~N");\r
238 Clazz.defineMethod (c$, "getMinimumSpan", \r
239 function (axis) {\r
240 this.checkRequests (axis);\r
241 var marginSpan = (axis == 0) ? this.getLeftInset () + this.getRightInset () : this.getTopInset () + this.getBottomInset ();\r
242 if (axis == this.majorAxis) {\r
243 return (this.majorRequest.minimum) + marginSpan;\r
244 } else {\r
245 return (this.minorRequest.minimum) + marginSpan;\r
246 }}, "~N");\r
247 Clazz.defineMethod (c$, "getMaximumSpan", \r
248 function (axis) {\r
249 this.checkRequests (axis);\r
250 var marginSpan = (axis == 0) ? this.getLeftInset () + this.getRightInset () : this.getTopInset () + this.getBottomInset ();\r
251 if (axis == this.majorAxis) {\r
252 return (this.majorRequest.maximum) + marginSpan;\r
253 } else {\r
254 return (this.minorRequest.maximum) + marginSpan;\r
255 }}, "~N");\r
256 Clazz.defineMethod (c$, "isAllocationValid", \r
257 function () {\r
258 return (this.majorAllocValid && this.minorAllocValid);\r
259 });\r
260 Clazz.overrideMethod (c$, "isBefore", \r
261 function (x, y, innerAlloc) {\r
262 if (this.majorAxis == 0) {\r
263 return (x < innerAlloc.x);\r
264 } else {\r
265 return (y < innerAlloc.y);\r
266 }}, "~N,~N,java.awt.Rectangle");\r
267 Clazz.overrideMethod (c$, "isAfter", \r
268 function (x, y, innerAlloc) {\r
269 if (this.majorAxis == 0) {\r
270 return (x > (innerAlloc.width + innerAlloc.x));\r
271 } else {\r
272 return (y > (innerAlloc.height + innerAlloc.y));\r
273 }}, "~N,~N,java.awt.Rectangle");\r
274 Clazz.overrideMethod (c$, "getViewAtPoint", \r
275 function (x, y, alloc) {\r
276 var n = this.getViewCount ();\r
277 if (this.majorAxis == 0) {\r
278 if (x < (alloc.x + this.majorOffsets[0])) {\r
279 this.childAllocation (0, alloc);\r
280 return this.getView (0);\r
281 }for (var i = 0; i < n; i++) {\r
282 if (x < (alloc.x + this.majorOffsets[i])) {\r
283 this.childAllocation (i - 1, alloc);\r
284 return this.getView (i - 1);\r
285 }}\r
286 this.childAllocation (n - 1, alloc);\r
287 return this.getView (n - 1);\r
288 } else {\r
289 if (y < (alloc.y + this.majorOffsets[0])) {\r
290 this.childAllocation (0, alloc);\r
291 return this.getView (0);\r
292 }for (var i = 0; i < n; i++) {\r
293 if (y < (alloc.y + this.majorOffsets[i])) {\r
294 this.childAllocation (i - 1, alloc);\r
295 return this.getView (i - 1);\r
296 }}\r
297 this.childAllocation (n - 1, alloc);\r
298 return this.getView (n - 1);\r
299 }}, "~N,~N,java.awt.Rectangle");\r
300 Clazz.overrideMethod (c$, "childAllocation", \r
301 function (index, alloc) {\r
302 alloc.x += this.getOffset (0, index);\r
303 alloc.y += this.getOffset (1, index);\r
304 alloc.width = this.getSpan (0, index);\r
305 alloc.height = this.getSpan (1, index);\r
306 }, "~N,java.awt.Rectangle");\r
307 Clazz.defineMethod (c$, "layout", \r
308 function (width, height) {\r
309 this.setSpanOnAxis (0, width);\r
310 this.setSpanOnAxis (1, height);\r
311 }, "~N,~N");\r
312 Clazz.defineMethod (c$, "getWidth", \r
313 function () {\r
314 var span;\r
315 if (this.majorAxis == 0) {\r
316 span = this.majorSpan;\r
317 } else {\r
318 span = this.minorSpan;\r
319 }span += this.getLeftInset () - this.getRightInset ();\r
320 return span;\r
321 });\r
322 Clazz.defineMethod (c$, "getHeight", \r
323 function () {\r
324 var span;\r
325 if (this.majorAxis == 1) {\r
326 span = this.majorSpan;\r
327 } else {\r
328 span = this.minorSpan;\r
329 }span += this.getTopInset () - this.getBottomInset ();\r
330 return span;\r
331 });\r
332 Clazz.defineMethod (c$, "layoutMajorAxis", \r
333 function (targetSpan, axis, offsets, spans) {\r
334 var preferred = 0;\r
335 var n = this.getViewCount ();\r
336 for (var i = 0; i < n; i++) {\r
337 var v = this.getView (i);\r
338 spans[i] = Clazz.floatToInt (v.getPreferredSpan (axis));\r
339 preferred += spans[i];\r
340 }\r
341 var desiredAdjustment = targetSpan - preferred;\r
342 var adjustmentFactor = 0.0;\r
343 var diffs = null;\r
344 if (desiredAdjustment != 0) {\r
345 var totalSpan = 0;\r
346 diffs =  Clazz.newIntArray (n, 0);\r
347 for (var i = 0; i < n; i++) {\r
348 var v = this.getView (i);\r
349 var tmp;\r
350 if (desiredAdjustment < 0) {\r
351 tmp = Clazz.floatToInt (v.getMinimumSpan (axis));\r
352 diffs[i] = spans[i] - tmp;\r
353 } else {\r
354 tmp = Clazz.floatToInt (v.getMaximumSpan (axis));\r
355 diffs[i] = tmp - spans[i];\r
356 }totalSpan += tmp;\r
357 }\r
358 var maximumAdjustment = Math.abs (totalSpan - preferred);\r
359 adjustmentFactor = desiredAdjustment / maximumAdjustment;\r
360 adjustmentFactor = Math.min (adjustmentFactor, 1.0);\r
361 adjustmentFactor = Math.max (adjustmentFactor, -1.0);\r
362 }var totalOffset = 0;\r
363 for (var i = 0; i < n; i++) {\r
364 offsets[i] = totalOffset;\r
365 if (desiredAdjustment != 0) {\r
366 var adjF = adjustmentFactor * diffs[i];\r
367 spans[i] += Math.round (adjF);\r
368 }totalOffset = Math.min (totalOffset + spans[i], 2147483647);\r
369 }\r
370 }, "~N,~N,~A,~A");\r
371 Clazz.defineMethod (c$, "layoutMinorAxis", \r
372 function (targetSpan, axis, offsets, spans) {\r
373 var n = this.getViewCount ();\r
374 for (var i = 0; i < n; i++) {\r
375 var v = this.getView (i);\r
376 var max = Clazz.floatToInt (v.getMaximumSpan (axis));\r
377 if (max < targetSpan) {\r
378 var align = v.getAlignment (axis);\r
379 offsets[i] = Clazz.floatToInt ((targetSpan - max) * align);\r
380 spans[i] = max;\r
381 } else {\r
382 var min = Clazz.floatToInt (v.getMinimumSpan (axis));\r
383 offsets[i] = 0;\r
384 spans[i] = Math.max (min, targetSpan);\r
385 }}\r
386 }, "~N,~N,~A,~A");\r
387 Clazz.defineMethod (c$, "calculateMajorAxisRequirements", \r
388 function (axis, r) {\r
389 var min = 0;\r
390 var pref = 0;\r
391 var max = 0;\r
392 var n = this.getViewCount ();\r
393 for (var i = 0; i < n; i++) {\r
394 var v = this.getView (i);\r
395 min += v.getMinimumSpan (axis);\r
396 pref += v.getPreferredSpan (axis);\r
397 max += v.getMaximumSpan (axis);\r
398 }\r
399 if (r == null) {\r
400 r =  new javax.swing.SizeRequirements ();\r
401 }r.alignment = 0.5;\r
402 r.minimum = Clazz.floatToInt (min);\r
403 r.preferred = Clazz.floatToInt (pref);\r
404 r.maximum = Clazz.floatToInt (max);\r
405 return r;\r
406 }, "~N,javax.swing.SizeRequirements");\r
407 Clazz.defineMethod (c$, "calculateMinorAxisRequirements", \r
408 function (axis, r) {\r
409 var min = 0;\r
410 var pref = 0;\r
411 var max = 2147483647;\r
412 var n = this.getViewCount ();\r
413 for (var i = 0; i < n; i++) {\r
414 var v = this.getView (i);\r
415 min = Math.max (Clazz.floatToInt (v.getMinimumSpan (axis)), min);\r
416 pref = Math.max (Clazz.floatToInt (v.getPreferredSpan (axis)), pref);\r
417 max = Math.max (Clazz.floatToInt (v.getMaximumSpan (axis)), max);\r
418 }\r
419 if (r == null) {\r
420 r =  new javax.swing.SizeRequirements ();\r
421 r.alignment = 0.5;\r
422 }r.preferred = pref;\r
423 r.minimum = min;\r
424 r.maximum = max;\r
425 return r;\r
426 }, "~N,javax.swing.SizeRequirements");\r
427 Clazz.defineMethod (c$, "checkRequests", \r
428 function (axis) {\r
429 if ((axis != 0) && (axis != 1)) {\r
430 throw  new IllegalArgumentException ("Invalid axis: " + axis);\r
431 }if (axis == this.majorAxis) {\r
432 if (!this.majorReqValid) {\r
433 this.majorRequest = this.calculateMajorAxisRequirements (axis, this.majorRequest);\r
434 this.majorReqValid = true;\r
435 }} else if (!this.minorReqValid) {\r
436 this.minorRequest = this.calculateMinorAxisRequirements (axis, this.minorRequest);\r
437 this.minorReqValid = true;\r
438 }}, "~N");\r
439 Clazz.defineMethod (c$, "baselineLayout", \r
440 function (targetSpan, axis, offsets, spans) {\r
441 var totalAscent = Clazz.floatToInt (targetSpan * this.getAlignment (axis));\r
442 var totalDescent = targetSpan - totalAscent;\r
443 var n = this.getViewCount ();\r
444 for (var i = 0; i < n; i++) {\r
445 var v = this.getView (i);\r
446 var align = v.getAlignment (axis);\r
447 var viewSpan;\r
448 if (v.getResizeWeight (axis) > 0) {\r
449 var minSpan = v.getMinimumSpan (axis);\r
450 var maxSpan = v.getMaximumSpan (axis);\r
451 if (align == 0.0) {\r
452 viewSpan = Math.max (Math.min (maxSpan, totalDescent), minSpan);\r
453 } else if (align == 1.0) {\r
454 viewSpan = Math.max (Math.min (maxSpan, totalAscent), minSpan);\r
455 } else {\r
456 var fitSpan = Math.min (totalAscent / align, totalDescent / (1.0 - align));\r
457 viewSpan = Math.max (Math.min (maxSpan, fitSpan), minSpan);\r
458 }} else {\r
459 viewSpan = v.getPreferredSpan (axis);\r
460 }offsets[i] = totalAscent - Clazz.floatToInt (viewSpan * align);\r
461 spans[i] = Clazz.floatToInt (viewSpan);\r
462 }\r
463 }, "~N,~N,~A,~A");\r
464 Clazz.defineMethod (c$, "baselineRequirements", \r
465 function (axis, r) {\r
466 var totalAscent =  new javax.swing.SizeRequirements ();\r
467 var totalDescent =  new javax.swing.SizeRequirements ();\r
468 if (r == null) {\r
469 r =  new javax.swing.SizeRequirements ();\r
470 }r.alignment = 0.5;\r
471 var n = this.getViewCount ();\r
472 for (var i = 0; i < n; i++) {\r
473 var v = this.getView (i);\r
474 var align = v.getAlignment (axis);\r
475 var span;\r
476 var ascent;\r
477 var descent;\r
478 span = v.getPreferredSpan (axis);\r
479 ascent = Clazz.floatToInt (align * span);\r
480 descent = Clazz.floatToInt (span - ascent);\r
481 totalAscent.preferred = Math.max (ascent, totalAscent.preferred);\r
482 totalDescent.preferred = Math.max (descent, totalDescent.preferred);\r
483 if (v.getResizeWeight (axis) > 0) {\r
484 span = v.getMinimumSpan (axis);\r
485 ascent = Clazz.floatToInt (align * span);\r
486 descent = Clazz.floatToInt (span - ascent);\r
487 totalAscent.minimum = Math.max (ascent, totalAscent.minimum);\r
488 totalDescent.minimum = Math.max (descent, totalDescent.minimum);\r
489 span = v.getMaximumSpan (axis);\r
490 ascent = Clazz.floatToInt (align * span);\r
491 descent = Clazz.floatToInt (span - ascent);\r
492 totalAscent.maximum = Math.max (ascent, totalAscent.maximum);\r
493 totalDescent.maximum = Math.max (descent, totalDescent.maximum);\r
494 } else {\r
495 totalAscent.minimum = Math.max (ascent, totalAscent.minimum);\r
496 totalDescent.minimum = Math.max (descent, totalDescent.minimum);\r
497 totalAscent.maximum = Math.max (ascent, totalAscent.maximum);\r
498 totalDescent.maximum = Math.max (descent, totalDescent.maximum);\r
499 }}\r
500 r.preferred = Math.min (totalAscent.preferred + totalDescent.preferred, 2147483647);\r
501 if (r.preferred > 0) {\r
502 r.alignment = totalAscent.preferred / r.preferred;\r
503 }if (r.alignment == 0.0) {\r
504 r.minimum = totalDescent.minimum;\r
505 r.maximum = totalDescent.maximum;\r
506 } else if (r.alignment == 1.0) {\r
507 r.minimum = totalAscent.minimum;\r
508 r.maximum = totalAscent.maximum;\r
509 } else {\r
510 r.minimum = Math.round (Math.max (totalAscent.minimum / r.alignment, totalDescent.minimum / (1.0 - r.alignment)));\r
511 r.maximum = Math.round (Math.min (totalAscent.maximum / r.alignment, totalDescent.maximum / (1.0 - r.alignment)));\r
512 }return r;\r
513 }, "~N,javax.swing.SizeRequirements");\r
514 Clazz.defineMethod (c$, "getOffset", \r
515 function (axis, childIndex) {\r
516 var offsets = (axis == this.majorAxis) ? this.majorOffsets : this.minorOffsets;\r
517 return offsets[childIndex];\r
518 }, "~N,~N");\r
519 Clazz.defineMethod (c$, "getSpan", \r
520 function (axis, childIndex) {\r
521 var spans = (axis == this.majorAxis) ? this.majorSpans : this.minorSpans;\r
522 return spans[childIndex];\r
523 }, "~N,~N");\r
524 Clazz.defineMethod (c$, "flipEastAndWestAtEnds", \r
525 function (position, bias) {\r
526 if (this.majorAxis == 1) {\r
527 var testPos = (bias === javax.swing.text.Position.Bias.Backward) ? Math.max (0, position - 1) : position;\r
528 var index = this.getViewIndexAtPosition (testPos);\r
529 if (index != -1) {\r
530 var v = this.getView (index);\r
531 if (v != null && Clazz.instanceOf (v, javax.swing.text.CompositeView)) {\r
532 return (v).flipEastAndWestAtEnds (position, bias);\r
533 }}}return false;\r
534 }, "~N,javax.swing.text.Position.Bias");\r
535 });\r