1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.LayoutManager2"], "java.awt.GridBagLayout", ["java.lang.IllegalArgumentException", "java.util.Arrays", "$.Hashtable", "java.awt.Component", "$.Dimension", "$.GridBagConstraints", "$.GridBagLayoutInfo", "$.Point", "$.Rectangle"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.defaultConstraints = null;
6 this.layoutInfo = null;
7 this.columnWidths = null;
8 this.rowHeights = null;
9 this.columnWeights = null;
10 this.rowWeights = null;
11 this.componentAdjusting = null;
12 this.rightToLeft = false;
13 Clazz.instantialize (this, arguments);
14 }, java.awt, "GridBagLayout", null, [java.awt.LayoutManager2, java.io.Serializable]);
15 Clazz.makeConstructor (c$,
17 this.comptable = new java.util.Hashtable ();
18 this.defaultConstraints = new java.awt.GridBagConstraints ();
20 Clazz.defineMethod (c$, "setConstraints",
21 function (comp, constraints) {
22 this.comptable.put (comp, constraints.clone ());
23 }, "java.awt.Component,java.awt.GridBagConstraints");
24 Clazz.defineMethod (c$, "getConstraints",
26 var constraints = this.comptable.get (comp);
27 if (constraints == null) {
28 this.setConstraints (comp, this.defaultConstraints);
29 constraints = this.comptable.get (comp);
30 }return constraints.clone ();
31 }, "java.awt.Component");
32 Clazz.defineMethod (c$, "lookupConstraints",
34 var constraints = this.comptable.get (comp);
35 if (constraints == null) {
36 this.setConstraints (comp, this.defaultConstraints);
37 constraints = this.comptable.get (comp);
39 }, "java.awt.Component");
40 Clazz.defineMethod (c$, "removeConstraints",
42 this.comptable.remove (comp);
43 }, "java.awt.Component");
44 Clazz.defineMethod (c$, "getLayoutOrigin",
46 var origin = new java.awt.Point (0, 0);
47 if (this.layoutInfo != null) {
48 origin.x = this.layoutInfo.startx;
49 origin.y = this.layoutInfo.starty;
52 Clazz.defineMethod (c$, "getLayoutDimensions",
54 if (this.layoutInfo == null) return Clazz.newIntArray (2, 0, 0);
55 var dim = Clazz.newIntArray (2, 0);
56 dim[0] = Clazz.newIntArray (this.layoutInfo.width, 0);
57 dim[1] = Clazz.newIntArray (this.layoutInfo.height, 0);
58 System.arraycopy (this.layoutInfo.minWidth, 0, dim[0], 0, this.layoutInfo.width);
59 System.arraycopy (this.layoutInfo.minHeight, 0, dim[1], 0, this.layoutInfo.height);
62 Clazz.defineMethod (c$, "getLayoutWeights",
64 if (this.layoutInfo == null) return Clazz.newDoubleArray (2, 0, 0);
65 var weights = Clazz.newDoubleArray (2, 0);
66 weights[0] = Clazz.newDoubleArray (this.layoutInfo.width, 0);
67 weights[1] = Clazz.newDoubleArray (this.layoutInfo.height, 0);
68 System.arraycopy (this.layoutInfo.weightX, 0, weights[0], 0, this.layoutInfo.width);
69 System.arraycopy (this.layoutInfo.weightY, 0, weights[1], 0, this.layoutInfo.height);
72 Clazz.defineMethod (c$, "location",
74 var loc = new java.awt.Point (0, 0);
77 if (this.layoutInfo == null) return loc;
78 d = this.layoutInfo.startx;
79 if (!this.rightToLeft) {
80 for (i = 0; i < this.layoutInfo.width; i++) {
81 d += this.layoutInfo.minWidth[i];
85 for (i = this.layoutInfo.width - 1; i >= 0; i--) {
87 d += this.layoutInfo.minWidth[i];
91 d = this.layoutInfo.starty;
92 for (i = 0; i < this.layoutInfo.height; i++) {
93 d += this.layoutInfo.minHeight[i];
99 Clazz.defineMethod (c$, "addLayoutComponent",
100 function (name, comp) {
101 }, "~S,java.awt.Component");
102 Clazz.defineMethod (c$, "addLayoutComponent",
103 function (comp, constraints) {
104 if (Clazz.instanceOf (constraints, java.awt.GridBagConstraints)) {
105 this.setConstraints (comp, constraints);
106 } else if (constraints != null) {
107 throw new IllegalArgumentException ("cannot add to layout: constraints must be a GridBagConstraint");
108 }}, "java.awt.Component,~O");
109 Clazz.overrideMethod (c$, "removeLayoutComponent",
111 this.removeConstraints (comp);
112 }, "java.awt.Component");
113 Clazz.overrideMethod (c$, "preferredLayoutSize",
115 var info = this.getLayoutInfo (parent, 2);
116 return this.getMinSize (parent, info);
117 }, "java.awt.Container");
118 Clazz.overrideMethod (c$, "minimumLayoutSize",
120 var info = this.getLayoutInfo (parent, 1);
121 return this.getMinSize (parent, info);
122 }, "java.awt.Container");
123 Clazz.overrideMethod (c$, "maximumLayoutSize",
125 return new java.awt.Dimension (2147483647, 2147483647);
126 }, "java.awt.Container");
127 Clazz.overrideMethod (c$, "getLayoutAlignmentX",
130 }, "java.awt.Container");
131 Clazz.overrideMethod (c$, "getLayoutAlignmentY",
134 }, "java.awt.Container");
135 Clazz.overrideMethod (c$, "invalidateLayout",
137 }, "java.awt.Container");
138 Clazz.overrideMethod (c$, "layoutContainer",
140 System.out.println ("GridBagLayout laying out " + parent);
141 this.arrangeGrid (parent);
142 }, "java.awt.Container");
143 Clazz.overrideMethod (c$, "toString",
145 return this.getClass ().getName ();
147 Clazz.defineMethod (c$, "getLayoutInfo",
148 function (parent, sizeflag) {
149 return this.GetLayoutInfo (parent, sizeflag);
150 }, "java.awt.Container,~N");
151 Clazz.defineMethod (c$, "preInitMaximumArraySizes",
153 var components = parent.getComponents ();
160 var preMaximumArrayXIndex = 0;
161 var preMaximumArrayYIndex = 0;
162 var returnArray = Clazz.newLongArray (2, 0);
163 for (var compId = 0; compId < components.length; compId++) {
164 comp = components[compId];
165 if (!comp.isVisible ()) {
167 }constraints = this.lookupConstraints (comp);
168 curX = constraints.gridx;
169 curY = constraints.gridy;
170 curWidth = constraints.gridwidth;
171 curHeight = constraints.gridheight;
173 curX = ++preMaximumArrayYIndex;
175 curY = ++preMaximumArrayXIndex;
176 }if (curWidth <= 0) {
178 }if (curHeight <= 0) {
180 }preMaximumArrayXIndex = Math.max (curY + curHeight, preMaximumArrayXIndex);
181 preMaximumArrayYIndex = Math.max (curX + curWidth, preMaximumArrayYIndex);
183 returnArray[0] = preMaximumArrayXIndex;
184 returnArray[1] = preMaximumArrayYIndex;
186 }, "java.awt.Container");
187 Clazz.defineMethod (c$, "GetLayoutInfo",
188 function (parent, sizeflag) {
194 var components = parent.getComponents ();
214 var maximumArrayXIndex = 0;
215 var maximumArrayYIndex = 0;
217 layoutWidth = layoutHeight = 0;
218 curRow = curCol = -1;
219 var arraySizes = this.preInitMaximumArraySizes (parent);
220 maximumArrayXIndex = (2 * arraySizes[0] > 2147483647) ? 2147483647 : 2 * arraySizes[0];
221 maximumArrayYIndex = (2 * arraySizes[1] > 2147483647) ? 2147483647 : 2 * arraySizes[1];
222 if (this.rowHeights != null) {
223 maximumArrayXIndex = Math.max (maximumArrayXIndex, this.rowHeights.length);
224 }if (this.columnWidths != null) {
225 maximumArrayYIndex = Math.max (maximumArrayYIndex, this.columnWidths.length);
226 }xMaxArray = Clazz.newIntArray (maximumArrayXIndex, 0);
227 yMaxArray = Clazz.newIntArray (maximumArrayYIndex, 0);
228 var hasBaseline = false;
229 for (compindex = 0; compindex < components.length; compindex++) {
230 comp = components[compindex];
231 if (!comp.isVisible ()) continue;
232 constraints = this.lookupConstraints (comp);
233 curX = constraints.gridx;
234 curY = constraints.gridy;
235 curWidth = constraints.gridwidth;
236 if (curWidth <= 0) curWidth = 1;
237 curHeight = constraints.gridheight;
238 if (curHeight <= 0) curHeight = 1;
239 if (curX < 0 && curY < 0) {
240 if (curRow >= 0) curY = curRow;
241 else if (curCol >= 0) curX = curCol;
245 for (i = curY; i < (curY + curHeight); i++) {
246 px = Math.max (px, xMaxArray[i]);
248 curX = px - curX - 1;
249 if (curX < 0) curX = 0;
250 } else if (curY < 0) {
252 for (i = curX; i < (curX + curWidth); i++) {
253 py = Math.max (py, yMaxArray[i]);
255 curY = py - curY - 1;
256 if (curY < 0) curY = 0;
257 }px = curX + curWidth;
258 if (layoutWidth < px) {
260 }py = curY + curHeight;
261 if (layoutHeight < py) {
263 }for (i = curX; i < (curX + curWidth); i++) {
266 for (i = curY; i < (curY + curHeight); i++) {
269 if (sizeflag == 2) d = comp.getPreferredSize ();
270 else d = comp.getMinimumSize ();
271 constraints.minWidth = d.width;
272 constraints.minHeight = d.height;
273 if (this.calculateBaseline (comp, constraints, d)) {
275 }if (constraints.gridheight == 0 && constraints.gridwidth == 0) curRow = curCol = -1;
276 if (constraints.gridheight == 0 && curRow < 0) curCol = curX + curWidth;
277 else if (constraints.gridwidth == 0 && curCol < 0) curRow = curY + curHeight;
279 if (this.columnWidths != null && layoutWidth < this.columnWidths.length) layoutWidth = this.columnWidths.length;
280 if (this.rowHeights != null && layoutHeight < this.rowHeights.length) layoutHeight = this.rowHeights.length;
281 r = new java.awt.GridBagLayoutInfo (layoutWidth, layoutHeight);
282 curRow = curCol = -1;
283 java.util.Arrays.fill (xMaxArray, 0);
284 java.util.Arrays.fill (yMaxArray, 0);
285 var maxAscent = null;
286 var maxDescent = null;
287 var baselineType = null;
289 r.maxAscent = maxAscent = Clazz.newIntArray (layoutHeight, 0);
290 r.maxDescent = maxDescent = Clazz.newIntArray (layoutHeight, 0);
291 r.baselineType = baselineType = Clazz.newShortArray (layoutHeight, 0);
292 r.$hasBaseline = true;
293 }for (compindex = 0; compindex < components.length; compindex++) {
294 comp = components[compindex];
295 if (!comp.isVisible ()) continue;
296 constraints = this.lookupConstraints (comp);
297 curX = constraints.gridx;
298 curY = constraints.gridy;
299 curWidth = constraints.gridwidth;
300 curHeight = constraints.gridheight;
301 if (curX < 0 && curY < 0) {
302 if (curRow >= 0) curY = curRow;
303 else if (curCol >= 0) curX = curCol;
306 if (curHeight <= 0) {
307 curHeight += r.height - curY;
308 if (curHeight < 1) curHeight = 1;
310 for (i = curY; i < (curY + curHeight); i++) px = Math.max (px, xMaxArray[i]);
312 curX = px - curX - 1;
313 if (curX < 0) curX = 0;
314 } else if (curY < 0) {
316 curWidth += r.width - curX;
317 if (curWidth < 1) curWidth = 1;
319 for (i = curX; i < (curX + curWidth); i++) {
320 py = Math.max (py, yMaxArray[i]);
322 curY = py - curY - 1;
323 if (curY < 0) curY = 0;
324 }if (curWidth <= 0) {
325 curWidth += r.width - curX;
326 if (curWidth < 1) curWidth = 1;
327 }if (curHeight <= 0) {
328 curHeight += r.height - curY;
329 if (curHeight < 1) curHeight = 1;
330 }px = curX + curWidth;
331 py = curY + curHeight;
332 for (i = curX; i < (curX + curWidth); i++) {
335 for (i = curY; i < (curY + curHeight); i++) {
338 if (constraints.gridheight == 0 && constraints.gridwidth == 0) curRow = curCol = -1;
339 if (constraints.gridheight == 0 && curRow < 0) curCol = curX + curWidth;
340 else if (constraints.gridwidth == 0 && curCol < 0) curRow = curY + curHeight;
341 constraints.tempX = curX;
342 constraints.tempY = curY;
343 constraints.tempWidth = curWidth;
344 constraints.tempHeight = curHeight;
345 anchor = constraints.anchor;
351 if (constraints.ascent >= 0) {
352 if (curHeight == 1) {
353 maxAscent[curY] = Math.max (maxAscent[curY], constraints.ascent);
354 maxDescent[curY] = Math.max (maxDescent[curY], constraints.descent);
356 if (constraints.baselineResizeBehavior === java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT) {
357 maxDescent[curY + curHeight - 1] = Math.max (maxDescent[curY + curHeight - 1], constraints.descent);
359 maxAscent[curY] = Math.max (maxAscent[curY], constraints.ascent);
360 }}if (constraints.baselineResizeBehavior === java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT) {
361 baselineType[curY + curHeight - 1] |= (1 << constraints.baselineResizeBehavior.ordinal ());
363 baselineType[curY] |= (1 << constraints.baselineResizeBehavior.ordinal ());
368 pixels_diff = constraints.minHeight + constraints.insets.top + constraints.ipady;
369 maxAscent[curY] = Math.max (maxAscent[curY], pixels_diff);
370 maxDescent[curY] = Math.max (maxDescent[curY], constraints.insets.bottom);
375 pixels_diff = constraints.minHeight + constraints.insets.bottom + constraints.ipady;
376 maxDescent[curY] = Math.max (maxDescent[curY], pixels_diff);
377 maxAscent[curY] = Math.max (maxAscent[curY], constraints.insets.top);
381 r.weightX = Clazz.newDoubleArray (maximumArrayYIndex, 0);
382 r.weightY = Clazz.newDoubleArray (maximumArrayXIndex, 0);
383 r.minWidth = Clazz.newIntArray (maximumArrayYIndex, 0);
384 r.minHeight = Clazz.newIntArray (maximumArrayXIndex, 0);
385 if (this.columnWidths != null) System.arraycopy (this.columnWidths, 0, r.minWidth, 0, this.columnWidths.length);
386 if (this.rowHeights != null) System.arraycopy (this.rowHeights, 0, r.minHeight, 0, this.rowHeights.length);
387 if (this.columnWeights != null) System.arraycopy (this.columnWeights, 0, r.weightX, 0, Math.min (r.weightX.length, this.columnWeights.length));
388 if (this.rowWeights != null) System.arraycopy (this.rowWeights, 0, r.weightY, 0, Math.min (r.weightY.length, this.rowWeights.length));
389 nextSize = 2147483647;
390 for (i = 1; i != 2147483647; i = nextSize, nextSize = 2147483647) {
391 for (compindex = 0; compindex < components.length; compindex++) {
392 comp = components[compindex];
393 if (!comp.isVisible ()) continue;
394 constraints = this.lookupConstraints (comp);
395 if (constraints.tempWidth == i) {
396 px = constraints.tempX + constraints.tempWidth;
397 weight_diff = constraints.weightx;
398 for (k = constraints.tempX; k < px; k++) weight_diff -= r.weightX[k];
400 if (weight_diff > 0.0) {
402 for (k = constraints.tempX; k < px; k++) weight += r.weightX[k];
404 for (k = constraints.tempX; weight > 0.0 && k < px; k++) {
405 var wt = r.weightX[k];
406 var dx = (wt * weight_diff) / weight;
411 r.weightX[px - 1] += weight_diff;
412 }pixels_diff = constraints.minWidth + constraints.ipadx + constraints.insets.left + constraints.insets.right;
413 for (k = constraints.tempX; k < px; k++) pixels_diff -= r.minWidth[k];
415 if (pixels_diff > 0) {
417 for (k = constraints.tempX; k < px; k++) weight += r.weightX[k];
419 for (k = constraints.tempX; weight > 0.0 && k < px; k++) {
420 var wt = r.weightX[k];
421 var dx = Clazz.doubleToInt ((wt * (pixels_diff)) / weight);
426 r.minWidth[px - 1] += pixels_diff;
427 }} else if (constraints.tempWidth > i && constraints.tempWidth < nextSize) nextSize = constraints.tempWidth;
428 if (constraints.tempHeight == i) {
429 py = constraints.tempY + constraints.tempHeight;
430 weight_diff = constraints.weighty;
431 for (k = constraints.tempY; k < py; k++) weight_diff -= r.weightY[k];
433 if (weight_diff > 0.0) {
435 for (k = constraints.tempY; k < py; k++) weight += r.weightY[k];
437 for (k = constraints.tempY; weight > 0.0 && k < py; k++) {
438 var wt = r.weightY[k];
439 var dy = (wt * weight_diff) / weight;
444 r.weightY[py - 1] += weight_diff;
447 switch (constraints.anchor) {
451 if (constraints.ascent >= 0) {
452 if (constraints.tempHeight == 1) {
453 pixels_diff = maxAscent[constraints.tempY] + maxDescent[constraints.tempY];
454 } else if (constraints.baselineResizeBehavior !== java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT) {
455 pixels_diff = maxAscent[constraints.tempY] + constraints.descent;
457 pixels_diff = constraints.ascent + maxDescent[constraints.tempY + constraints.tempHeight - 1];
462 pixels_diff = constraints.insets.top + constraints.minHeight + constraints.ipady + maxDescent[constraints.tempY];
467 pixels_diff = maxAscent[constraints.tempY] + constraints.minHeight + constraints.insets.bottom + constraints.ipady;
470 }if (pixels_diff == -1) {
471 pixels_diff = constraints.minHeight + constraints.ipady + constraints.insets.top + constraints.insets.bottom;
472 }for (k = constraints.tempY; k < py; k++) pixels_diff -= r.minHeight[k];
474 if (pixels_diff > 0) {
476 for (k = constraints.tempY; k < py; k++) weight += r.weightY[k];
478 for (k = constraints.tempY; weight > 0.0 && k < py; k++) {
479 var wt = r.weightY[k];
480 var dy = Clazz.doubleToInt ((wt * (pixels_diff)) / weight);
481 r.minHeight[k] += dy;
485 r.minHeight[py - 1] += pixels_diff;
486 }} else if (constraints.tempHeight > i && constraints.tempHeight < nextSize) nextSize = constraints.tempHeight;
490 }}, "java.awt.Container,~N");
491 Clazz.defineMethod (c$, "calculateBaseline",
492 function (c, constraints, size) {
493 var anchor = constraints.anchor;
494 if (anchor == 256 || anchor == 512 || anchor == 768) {
495 var w = size.width + constraints.ipadx;
496 var h = size.height + constraints.ipady;
497 constraints.ascent = c.getBaseline (w, h);
498 if (constraints.ascent >= 0) {
499 var baseline = constraints.ascent;
500 constraints.descent = h - constraints.ascent + constraints.insets.bottom;
501 constraints.ascent += constraints.insets.top;
502 constraints.baselineResizeBehavior = c.getBaselineResizeBehavior ();
503 constraints.centerPadding = 0;
504 if (constraints.baselineResizeBehavior === java.awt.Component.BaselineResizeBehavior.CENTER_OFFSET) {
505 var nextBaseline = c.getBaseline (w, h + 1);
506 constraints.centerOffset = baseline - Clazz.doubleToInt (h / 2);
508 if (baseline != nextBaseline) {
509 constraints.centerPadding = 1;
510 }} else if (baseline == nextBaseline) {
511 constraints.centerOffset--;
512 constraints.centerPadding = 1;
515 constraints.ascent = -1;
517 }}, "java.awt.Component,java.awt.GridBagConstraints,java.awt.Dimension");
518 Clazz.defineMethod (c$, "adjustForGravity",
519 function (constraints, r) {
520 this.AdjustForGravity (constraints, r);
521 }, "java.awt.GridBagConstraints,java.awt.Rectangle");
522 Clazz.defineMethod (c$, "AdjustForGravity",
523 function (constraints, r) {
527 var cellHeight = r.height;
528 if (!this.rightToLeft) {
529 r.x += constraints.insets.left;
531 r.x -= r.width - constraints.insets.right;
532 }r.width -= (constraints.insets.left + constraints.insets.right);
533 r.y += constraints.insets.top;
534 r.height -= (constraints.insets.top + constraints.insets.bottom);
536 if ((constraints.fill != 2 && constraints.fill != 1) && (r.width > (constraints.minWidth + constraints.ipadx))) {
537 diffx = r.width - (constraints.minWidth + constraints.ipadx);
538 r.width = constraints.minWidth + constraints.ipadx;
540 if ((constraints.fill != 3 && constraints.fill != 1) && (r.height > (constraints.minHeight + constraints.ipady))) {
541 diffy = r.height - (constraints.minHeight + constraints.ipady);
542 r.height = constraints.minHeight + constraints.ipady;
543 }switch (constraints.anchor) {
545 r.x += Clazz.doubleToInt (diffx / 2);
546 this.alignOnBaseline (constraints, r, cellY, cellHeight);
549 if (this.rightToLeft) {
551 }this.alignOnBaseline (constraints, r, cellY, cellHeight);
554 if (!this.rightToLeft) {
556 }this.alignOnBaseline (constraints, r, cellY, cellHeight);
559 r.x += Clazz.doubleToInt (diffx / 2);
560 this.alignAboveBaseline (constraints, r, cellY, cellHeight);
563 if (this.rightToLeft) {
565 }this.alignAboveBaseline (constraints, r, cellY, cellHeight);
568 if (!this.rightToLeft) {
570 }this.alignAboveBaseline (constraints, r, cellY, cellHeight);
573 r.x += Clazz.doubleToInt (diffx / 2);
574 this.alignBelowBaseline (constraints, r, cellY, cellHeight);
577 if (this.rightToLeft) {
579 }this.alignBelowBaseline (constraints, r, cellY, cellHeight);
582 if (!this.rightToLeft) {
584 }this.alignBelowBaseline (constraints, r, cellY, cellHeight);
587 r.x += Clazz.doubleToInt (diffx / 2);
588 r.y += Clazz.doubleToInt (diffy / 2);
592 r.x += Clazz.doubleToInt (diffx / 2);
599 r.y += Clazz.doubleToInt (diffy / 2);
607 r.x += Clazz.doubleToInt (diffx / 2);
614 r.y += Clazz.doubleToInt (diffy / 2);
619 if (this.rightToLeft) {
621 }r.y += Clazz.doubleToInt (diffy / 2);
624 if (!this.rightToLeft) {
626 }r.y += Clazz.doubleToInt (diffy / 2);
629 if (this.rightToLeft) {
633 if (!this.rightToLeft) {
637 if (this.rightToLeft) {
642 if (!this.rightToLeft) {
647 throw new IllegalArgumentException ("illegal anchor value");
649 }, "java.awt.GridBagConstraints,java.awt.Rectangle");
650 Clazz.defineMethod (c$, "alignOnBaseline",
651 function (cons, r, cellY, cellHeight) {
652 if (cons.ascent >= 0) {
653 if (cons.baselineResizeBehavior === java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT) {
654 var maxY = cellY + cellHeight - this.layoutInfo.maxDescent[cons.tempY + cons.tempHeight - 1] + cons.descent - cons.insets.bottom;
655 if (!cons.isVerticallyResizable ()) {
656 r.y = maxY - cons.minHeight;
657 r.height = cons.minHeight;
659 r.height = maxY - cellY - cons.insets.top;
662 var ascent = cons.ascent;
663 if (this.layoutInfo.hasConstantDescent (cons.tempY)) {
664 baseline = cellHeight - this.layoutInfo.maxDescent[cons.tempY];
666 baseline = this.layoutInfo.maxAscent[cons.tempY];
667 }if (cons.baselineResizeBehavior === java.awt.Component.BaselineResizeBehavior.OTHER) {
669 ascent = this.componentAdjusting.getBaseline (r.width, r.height);
671 ascent += cons.insets.top;
672 }if (ascent >= 0 && ascent <= baseline) {
673 if (baseline + (r.height - ascent - cons.insets.top) <= cellHeight - cons.insets.bottom) {
675 } else if (cons.isVerticallyResizable ()) {
676 var ascent2 = this.componentAdjusting.getBaseline (r.width, cellHeight - cons.insets.bottom - baseline + ascent);
678 ascent2 += cons.insets.top;
679 }if (ascent2 >= 0 && ascent2 <= ascent) {
680 r.height = cellHeight - cons.insets.bottom - baseline + ascent;
684 ascent = cons.ascent;
685 r.width = cons.minWidth;
686 r.height = cons.minHeight;
687 }}r.y = cellY + baseline - ascent + cons.insets.top;
688 if (cons.isVerticallyResizable ()) {
689 switch (cons.baselineResizeBehavior) {
690 case java.awt.Component.BaselineResizeBehavior.CONSTANT_ASCENT:
691 r.height = Math.max (cons.minHeight, cellY + cellHeight - r.y - cons.insets.bottom);
693 case java.awt.Component.BaselineResizeBehavior.CENTER_OFFSET:
695 var upper = r.y - cellY - cons.insets.top;
696 var lower = cellY + cellHeight - r.y - cons.minHeight - cons.insets.bottom;
697 var delta = Math.min (upper, lower);
699 if (delta > 0 && Clazz.doubleToInt ((cons.minHeight + cons.centerPadding + delta) / 2) + cons.centerOffset != baseline) {
701 }r.height = cons.minHeight + delta;
702 r.y = cellY + baseline - Clazz.doubleToInt ((r.height + cons.centerPadding) / 2) - cons.centerOffset;
704 case java.awt.Component.BaselineResizeBehavior.OTHER:
710 this.centerVertically (cons, r, cellHeight);
711 }}, "java.awt.GridBagConstraints,java.awt.Rectangle,~N,~N");
712 Clazz.defineMethod (c$, "alignAboveBaseline",
713 function (cons, r, cellY, cellHeight) {
714 if (this.layoutInfo.hasBaseline (cons.tempY)) {
716 if (this.layoutInfo.hasConstantDescent (cons.tempY)) {
717 maxY = cellY + cellHeight - this.layoutInfo.maxDescent[cons.tempY];
719 maxY = cellY + this.layoutInfo.maxAscent[cons.tempY];
720 }if (cons.isVerticallyResizable ()) {
721 r.y = cellY + cons.insets.top;
722 r.height = maxY - r.y;
724 r.height = cons.minHeight + cons.ipady;
725 r.y = maxY - r.height;
727 this.centerVertically (cons, r, cellHeight);
728 }}, "java.awt.GridBagConstraints,java.awt.Rectangle,~N,~N");
729 Clazz.defineMethod (c$, "alignBelowBaseline",
730 function (cons, r, cellY, cellHeight) {
731 if (this.layoutInfo.hasBaseline (cons.tempY)) {
732 if (this.layoutInfo.hasConstantDescent (cons.tempY)) {
733 r.y = cellY + cellHeight - this.layoutInfo.maxDescent[cons.tempY];
735 r.y = cellY + this.layoutInfo.maxAscent[cons.tempY];
736 }if (cons.isVerticallyResizable ()) {
737 r.height = cellY + cellHeight - r.y - cons.insets.bottom;
739 this.centerVertically (cons, r, cellHeight);
740 }}, "java.awt.GridBagConstraints,java.awt.Rectangle,~N,~N");
741 Clazz.defineMethod (c$, "centerVertically",
742 function (cons, r, cellHeight) {
743 if (!cons.isVerticallyResizable ()) {
744 r.y += Math.max (0, Clazz.doubleToInt ((cellHeight - cons.insets.top - cons.insets.bottom - cons.minHeight - cons.ipady) / 2));
745 }}, "java.awt.GridBagConstraints,java.awt.Rectangle,~N");
746 Clazz.defineMethod (c$, "getMinSize",
747 function (parent, info) {
748 return this.GetMinSize (parent, info);
749 }, "java.awt.Container,java.awt.GridBagLayoutInfo");
750 Clazz.defineMethod (c$, "GetMinSize",
751 function (parent, info) {
752 var d = new java.awt.Dimension ();
755 var insets = parent.getInsets ();
757 for (i = 0; i < info.width; i++) t += info.minWidth[i];
759 d.width = t + insets.left + insets.right;
761 for (i = 0; i < info.height; i++) t += info.minHeight[i];
763 d.height = t + insets.top + insets.bottom;
765 }, "java.awt.Container,java.awt.GridBagLayoutInfo");
766 Clazz.defineMethod (c$, "arrangeGrid",
768 this.ArrangeGrid (parent);
769 }, "java.awt.Container");
770 Clazz.defineMethod (c$, "ArrangeGrid",
775 var insets = parent.getInsets ();
776 var components = parent.getComponents ();
778 var r = new java.awt.Rectangle ();
784 this.rightToLeft = !parent.getComponentOrientation ().isLeftToRight ();
785 if (components.length == 0 && (this.columnWidths == null || this.columnWidths.length == 0) && (this.rowHeights == null || this.rowHeights.length == 0)) {
787 }info = this.getLayoutInfo (parent, 2);
788 d = this.getMinSize (parent, info);
789 if (parent.width < d.width || parent.height < d.height) {
790 info = this.getLayoutInfo (parent, 1);
791 d = this.getMinSize (parent, info);
792 }this.layoutInfo = info;
795 diffw = parent.width - r.width;
798 for (i = 0; i < info.width; i++) weight += info.weightX[i];
801 for (i = 0; i < info.width; i++) {
802 var dx = Clazz.doubleToInt (((diffw) * info.weightX[i]) / weight);
803 info.minWidth[i] += dx;
805 if (info.minWidth[i] < 0) {
806 r.width -= info.minWidth[i];
807 info.minWidth[i] = 0;
809 }diffw = parent.width - r.width;
812 }diffh = parent.height - r.height;
815 for (i = 0; i < info.height; i++) weight += info.weightY[i];
818 for (i = 0; i < info.height; i++) {
819 var dy = Clazz.doubleToInt (((diffh) * info.weightY[i]) / weight);
820 info.minHeight[i] += dy;
822 if (info.minHeight[i] < 0) {
823 r.height -= info.minHeight[i];
824 info.minHeight[i] = 0;
826 }diffh = parent.height - r.height;
829 }info.startx = Clazz.doubleToInt (diffw / 2) + insets.left;
830 info.starty = Clazz.doubleToInt (diffh / 2) + insets.top;
831 for (compindex = 0; compindex < components.length; compindex++) {
832 comp = components[compindex];
833 if (!comp.isVisible ()) {
835 }constraints = this.lookupConstraints (comp);
836 if (!this.rightToLeft) {
838 for (i = 0; i < constraints.tempX; i++) r.x += info.minWidth[i];
841 r.x = parent.width - (Clazz.doubleToInt (diffw / 2) + insets.right);
842 for (i = 0; i < constraints.tempX; i++) r.x -= info.minWidth[i];
845 for (i = 0; i < constraints.tempY; i++) r.y += info.minHeight[i];
848 for (i = constraints.tempX; i < (constraints.tempX + constraints.tempWidth); i++) {
849 r.width += info.minWidth[i];
852 for (i = constraints.tempY; i < (constraints.tempY + constraints.tempHeight); i++) {
853 r.height += info.minHeight[i];
855 this.componentAdjusting = comp;
856 this.adjustForGravity (constraints, r);
863 }if ((r.width <= 0) || (r.height <= 0)) {
864 comp.setBounds (0, 0, 0, 0);
866 if (comp.x != r.x || comp.y != r.y || comp.width != r.width || comp.height != r.height) {
867 comp.setBounds (r.x, r.y, r.width, r.height);
869 }, "java.awt.Container");
870 Clazz.defineStatics (c$,
871 "EMPIRICMULTIPLIER", 2,